摘要: 代码:public class Solution { public List spiralOrder(int[][] matrix) { List resultList = new ArrayList(); int row = matrix.length; ... 阅读全文
posted @ 2016-01-19 10:27 爱推理的骑士 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Iteration:public class Solution { public int maxSubArray(int[] nums) { int start = 0, end = nums.length-1; //return sumSubArray(nums,... 阅读全文
posted @ 2016-01-19 07:33 爱推理的骑士 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 注意 Integer.MIN_VALUE取负 溢出的情况 所以加入了long data type;代码:public class Solution { public double myPow(double x, int n) { int flag = 0; if(n... 阅读全文
posted @ 2016-01-18 14:39 爱推理的骑士 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 代码:public class Solution { public void rotate(int[][] matrix) { int n = matrix.length; for(int i = 0; i < n/2; i++){ int n... 阅读全文
posted @ 2016-01-18 13:19 爱推理的骑士 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 用Permutations的思路就能解决,代码不用改。代码:public void permute_array(int[] nums, int len){ if(flag) return; List list = new ArrayList(); for(i... 阅读全文
posted @ 2016-01-18 11:18 爱推理的骑士 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 代码:public class Solution { List> resultList = new ArrayList(); boolean flag = false; public List> permute(int[] nums) { int len = nums... 阅读全文
posted @ 2016-01-18 11:02 爱推理的骑士 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 在combination sum的基础上用的hashset做,代码:public class Solution { Set> set = new HashSet(); boolean flag = false; public List> combinationSum2(int[] ... 阅读全文
posted @ 2016-01-18 07:11 爱推理的骑士 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 添加两个List:List listSum 存储对应组合的和;List> list 存储可能的组合resultList存储和==target的组合代码:public class Solution { public List listSum; public List> list; p... 阅读全文
posted @ 2016-01-17 13:17 爱推理的骑士 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Recursion:代码:public class Solution { public int searchInsert(int[] nums, int target) { int len = nums.length; if(len == 0) return 0; ... 阅读全文
posted @ 2016-01-17 05:02 爱推理的骑士 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 注意index不要出现out of bounds的情况:代码:public class Solution { public int[] searchRange(int[] nums, int target) { int len = nums.length; int ... 阅读全文
posted @ 2016-01-17 04:08 爱推理的骑士 阅读(131) 评论(0) 推荐(0) 编辑