摘要:
这题非常复杂。牛客网上对应的题目对结果要求比较苛刻,所以要调整。整体思路是:先放进去一个,然后第二个来的时候插入到已有的,并且把自己也放进去。public static ArrayList> getSubsets(int[] a, int n){ ArrayList> res = n... 阅读全文
posted @ 2015-12-29 18:56
仔细思考一切
阅读(161)
评论(0)
推荐(0)
摘要:
魔术索引1:此外下一次应该看看课本上的方法。 public boolean findMagicIndex(int[] A, int n){ for(int i = 0; i < A.length; i++){ if(i == A[i]) { ... 阅读全文
posted @ 2015-12-29 11:42
仔细思考一切
阅读(198)
评论(0)
推荐(0)
摘要:
这道题只需要把障碍点都设为0就可以了。public static int countWays(int[][] map,int x, int y){ if( x < 0 || y < 0) return -1; int[][] dp = new int[x][y]; ... 阅读全文
posted @ 2015-12-29 11:33
仔细思考一切
阅读(224)
评论(0)
推荐(0)
摘要:
这题就是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
仔细思考一切
阅读(216)
评论(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
仔细思考一切
阅读(176)
评论(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
仔细思考一切
阅读(193)
评论(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
仔细思考一切
阅读(196)
评论(0)
推荐(0)

浙公网安备 33010602011771号