摘要:
public class Solution { public ArrayList insert(ArrayList intervals, Interval newInterval) { ArrayList res = new ArrayList(); for(Int... 阅读全文
摘要:
怎么写comparator是要会的public class Solution { public ArrayList merge(ArrayList intervals) { if(intervals==null || intervals.size() res = new Arra... 阅读全文
摘要:
details killpublic class Solution { public ArrayList spiralOrder(int[][] matrix) { ArrayList res = new ArrayList(); if(matrix==null |... 阅读全文
摘要:
主要是boundary的条件public class Solution { public void rotate(int[][] matrix) { if(matrix==null || matrix.length==0 || matrix[0].length==0) retur... 阅读全文
摘要:
public class Solution { public int maxProduct(int[] A) { int res = A[0]; // max is local max, res is global max int tmax = res, tmin ... 阅读全文
摘要:
refhttp://blog.csdn.net/linhuanmars/article/details/21314059DP经典题目,关于怎么动首尾部分,ref说的很明白public class Solution { public int maxSubArray(int[] A) { ... 阅读全文
摘要:
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 ... 阅读全文
摘要:
主要是思想,坐标和值什么的容易搞混public class Solution { public int firstMissingPositive(int[] A) { for(int i=0; i0 && A[i]<=A.length && A[i] != A[A[i]-1] )... 阅读全文
摘要:
比较典型的helper的题目,现在我还搞不太清楚dfs之类的,只能用helper来统称了,你明白那个调调就行public class Solution { public ArrayList> combinationSum(int[] candidates, int target) { ... 阅读全文
摘要:
二分,多设立一个返回条件变可以继承二分法ublic class Solution { public int searchInsert(int[] A, int target) { int l = 0, r = A.length-1; while(lt... 阅读全文