上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页
摘要: 这题就是dp的一般题目 public static int countWays(int x, int y){ if( x < 0 || y < 0) return -1; int[][] dp = new int[x][y]; ... 阅读全文
posted @ 2015-12-29 11:26 创业-李春跃-增长黑客 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 注意:错误主要在溢出问题上。所以不设置int,而是long。 public static int countWays(int n){ if(n == 1) return 1; if(n == 2) return 2; if(n == 3) re... 阅读全文
posted @ 2015-12-29 11:18 创业-李春跃-增长黑客 阅读(170) 评论(0) 推荐(0) 编辑
摘要: public static int[] getCloseNumber(int x){ int[] res = new int[2]; int i = 1; int num = oneNumber(x); while(res[0] == ... 阅读全文
posted @ 2015-12-29 11:01 创业-李春跃-增长黑客 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 注意:仔细注意位置。 public static int[] renderPixel(int[] screen, int x, int y){ int[] ans = new int[screen.length ]; int[] tmp = new int[scre... 阅读全文
posted @ 2015-12-29 09:52 创业-李春跃-增长黑客 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 注意:1,除法那里b+=b是错的。b一直在改变。 2,仔细一点。import java.util.*;public class AddSubstitution { public int calc(int a, int b, int type) { // write code... 阅读全文
posted @ 2015-12-28 15:45 创业-李春跃-增长黑客 阅读(243) 评论(0) 推荐(0) 编辑
摘要: //注意,1,要判断null;2,要注意ArrayList直接复制会被一起改变。要通过new的方式来操作。public class Solution { public static void main(String[] args){ TreeNode root = new Tre... 阅读全文
posted @ 2015-12-28 11:53 创业-李春跃-增长黑客 阅读(188) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class LCA { public static int getLCA(int a, int b){ if(a b){ a = a/2; ... 阅读全文
posted @ 2015-12-28 09:17 创业-李春跃-增长黑客 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 注意:就算斜率相等,但是,如果截距也相等,那么是属于相交,所以要特殊判断。public class CrossLine { public boolean checkCrossLine(double s1, double s2, double y1, double y2) { // ... 阅读全文
posted @ 2015-12-25 09:27 创业-李春跃-增长黑客 阅读(141) 评论(0) 推荐(0) 编辑
摘要: public class Ants { public double antsCollision(int n) { // write code here return (1 - Math.pow(0.5,n-1)); }} 阅读全文
posted @ 2015-12-25 09:13 创业-李春跃-增长黑客 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 这道题要利用101010来&。如下答案:public class Exchange { public int exchangeOddEven(int x) { // write code here int res =(((x & 0x55555555)>1)); ... 阅读全文
posted @ 2015-12-24 22:18 创业-李春跃-增长黑客 阅读(187) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页