摘要: public class Solution { public ArrayList insert(ArrayList intervals, Interval newInterval) { ArrayList res = new ArrayList(); for(Int... 阅读全文
posted @ 2015-04-15 01:30 世界到处都是小星星 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 怎么写comparator是要会的public class Solution { public ArrayList merge(ArrayList intervals) { if(intervals==null || intervals.size() res = new Arra... 阅读全文
posted @ 2015-04-15 00:49 世界到处都是小星星 阅读(138) 评论(0) 推荐(0) 编辑
摘要: details killpublic class Solution { public ArrayList spiralOrder(int[][] matrix) { ArrayList res = new ArrayList(); if(matrix==null |... 阅读全文
posted @ 2015-04-14 12:20 世界到处都是小星星 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 主要是boundary的条件public class Solution { public void rotate(int[][] matrix) { if(matrix==null || matrix.length==0 || matrix[0].length==0) retur... 阅读全文
posted @ 2015-04-14 12:00 世界到处都是小星星 阅读(97) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int maxProduct(int[] A) { int res = A[0]; // max is local max, res is global max int tmax = res, tmin ... 阅读全文
posted @ 2015-04-14 11:31 世界到处都是小星星 阅读(96) 评论(0) 推荐(0) 编辑
摘要: refhttp://blog.csdn.net/linhuanmars/article/details/21314059DP经典题目,关于怎么动首尾部分,ref说的很明白public class Solution { public int maxSubArray(int[] A) { ... 阅读全文
posted @ 2015-04-14 10:52 世界到处都是小星星 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Jump IGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your ... 阅读全文
posted @ 2015-04-14 10:28 世界到处都是小星星 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 主要是思想,坐标和值什么的容易搞混public class Solution { public int firstMissingPositive(int[] A) { for(int i=0; i0 && A[i]<=A.length && A[i] != A[A[i]-1] )... 阅读全文
posted @ 2015-04-14 07:40 世界到处都是小星星 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 比较典型的helper的题目,现在我还搞不太清楚dfs之类的,只能用helper来统称了,你明白那个调调就行public class Solution { public ArrayList> combinationSum(int[] candidates, int target) { ... 阅读全文
posted @ 2015-04-14 06:59 世界到处都是小星星 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 二分,多设立一个返回条件变可以继承二分法ublic class Solution { public int searchInsert(int[] A, int target) { int l = 0, r = A.length-1; while(lt... 阅读全文
posted @ 2015-04-14 06:25 世界到处都是小星星 阅读(151) 评论(0) 推荐(0) 编辑