上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页
摘要: 注意:错误主要在溢出问题上。所以不设置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 创业-李春跃-增长黑客 阅读(168) 评论(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 创业-李春跃-增长黑客 阅读(189) 评论(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 创业-李春跃-增长黑客 阅读(194) 评论(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 创业-李春跃-增长黑客 阅读(241) 评论(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 创业-李春跃-增长黑客 阅读(187) 评论(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 创业-李春跃-增长黑客 阅读(140) 评论(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 创业-李春跃-增长黑客 阅读(201) 评论(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 创业-李春跃-增长黑客 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 自己的: public static int calcCost(int A,int B){ int ans = 1; int temp = A ^ B; while(temp != 1){ if(temp % 2 == 1) an... 阅读全文
posted @ 2015-12-24 17:23 创业-李春跃-增长黑客 阅读(157) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页