摘要:
经典问题,可以把周边都做了,详见ref http://blog.csdn.net/linhuanmars/article/details/19949159public class Solution { public int lengthOfLongestSubstring(String s) ... 阅读全文
摘要:
题目看不到,所以网上搜刮http://www.danielbit.com/blog/puzzle/leetcode/leetcode-missing-ranges学习了一下public class Solution { public List findMissingRanges(int[] v... 阅读全文
摘要:
public class Solution { public void rotate(int[] nums, int k) { if(nums==null||nums.length<2||k<1) return; int n = nums.length; ... 阅读全文
摘要:
很有趣的一个算法,不过好像除此之外用处不大ref http://www.geeksforgeeks.org/majority-element/public int majorityElement(int[] num) { if(num.length<3) return num[0]; ... 阅读全文
摘要:
public class Solution { public int findPeakElement(int[] num) { // binary search http://siddontang.gitbooks.io/leetcode-solution/content/arr... 阅读全文
摘要:
之前一步一步存的方法略复杂啊,其实直接二分扔就可以咯这里直接给个II的解法,和I多个冗余挪位的判断public class Solution { public int findMin(int[] nums) { int min = nums[0]; int l=0,... 阅读全文
摘要:
总结帖http://blog.csdn.net/linhuanmars/article/details/39366817code 参考帖http://www.cnblogs.com/springfor/p/3869981.htmlhttp://blog.csdn.net/linhuanmars/ar... 阅读全文
摘要:
public class Solution { public int maxProfit(List prices) { // http://blog.csdn.net/linhuanmars/article/details/23236995 if(prices==n... 阅读全文
摘要:
这几道题最好连着做, 模式就是loc 和global比,难点在于求出loc,咦,我做过这个梦吔I 只能交易一次,那么loc就和0比 loc = max(loc+diff, 0)为啥是loc+当天diff呢?比如 1,2,4, 1买进,2-1的差价在loc里存着,到了4 的时候4和1 的差价=4-2 ... 阅读全文
摘要:
还是细节容易错画个图11 21 2 31 2 3 4很容易就出来了额public class Solution { public int minimumTotal(List> triangle) { int m = triangle.size() ; if(m==1... 阅读全文