摘要: 这道题没什么难度,但是之前看到过一种方法写得很好看。 因为这道题不是加上一位数,是加1,所以只有两种情况: 1. 该位是9,所以变成0,循环继续 2. 该位不是9,那就这位+1,然后返回 如果进行完了循环仍没有返回,说明整个数都是999999,那么就需要补一位,并且这个数是类似于100000...这 阅读全文
posted @ 2016-02-29 10:18 warmland 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 只比1多了一句话 if(i > 0 && used[i-1] == true && nums[i] == nums[i-1]){ continue; } 1 public List<List<Integer>> permute(int[] nums) { 2 List<List<Integer>> 阅读全文
posted @ 2016-02-29 04:15 warmland 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 和combinations比起来,需要多加一个used的数组标记这个数字有没有被用过。 1 public List<List<Integer>> permute(int[] nums) { 2 List<List<Integer>> res = new ArrayList<List<Integer> 阅读全文
posted @ 2016-02-29 04:00 warmland 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 把两个数反过来算 1 public String multiply(String num1, String num2) { 2 if(num1 == null || num1.length() == 0 || num2 == null || num2.length() == 0) { 3 retur 阅读全文
posted @ 2016-02-29 03:34 warmland 阅读(128) 评论(0) 推荐(0) 编辑