
Two pointers
文章平均质量分 74
yanrui92
这个作者很懒,什么都没留下…
展开
-
leetcode-4sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Element原创 2015-01-08 05:02:03 · 275 阅读 · 0 评论 -
leetcode-3Sum总结
public class Solution { public List> threeSum(int[] num) { ArrayList> result=new ArrayList>(); int len=num.length; if(len==0)return result; Arrays.sort(num);原创 2015-01-06 03:26:58 · 385 阅读 · 0 评论 -
leetcode-trapping rain water
Trapping rain water的最naive的方法:onepass没有注意到的问题:1一个container的两端应该是取最小的高度。2在找第一个容器的左端的时候没有注意到数组的下标的界限的问题!注意当数组的下标有变化的时候一定紧跟着不要忘记对其范围进行限制。3解题思路是:先找到第一个容器的最左端的点,然后用一个函数去找这个容器的右端,这个右端或者是大于等于这个容器的左端,原创 2015-01-08 04:43:34 · 387 阅读 · 0 评论 -
leetcode-3 closest
题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exac原创 2015-01-08 04:52:00 · 334 阅读 · 0 评论 -
leetcode-two sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2015-01-20 00:51:36 · 257 阅读 · 0 评论