![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
two pointer
feeeeeeet
这个作者很懒,什么都没留下…
展开
-
Leetcode 16. 3Sum Closest
Extend from Leetcode 15 class Solution { public int threeSumClosest(int[] nums, int target) { int minDis=0; int res=0; if (nums == null || nums.length < 3) return res; ...原创 2018-11-14 05:53:50 · 75 阅读 · 0 评论 -
Leetcode 18. 4Sum
Extend from 3Sum. Add another for loop. Slow Version class Solution { public List&lt;List&lt;Integer&gt;&gt; fourSum(int[] nums, int target) { List&lt;List&lt;Integer&gt;&gt; r原创 2018-11-14 08:37:01 · 70 阅读 · 0 评论 -
Leetcode 27. Remove Element
class Solution { public int removeElement(int[] nums, int val) { int left=0; int right=nums.length-1; if(right<0){ return nums.length; } whil...原创 2018-11-16 07:09:00 · 81 阅读 · 0 评论 -
Leetcode 75. Sort Colors
Two pointers left points to the position that 0 ends right points to the position that 2 begins class Solution: def sortColors(self, nums): """ :type nums: List[int] :rtype...原创 2018-12-29 04:48:23 · 72 阅读 · 0 评论 -
Leetcode 80. Remove Duplicates from Sorted Array II
2 methods class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 newT...原创 2018-12-30 09:35:30 · 74 阅读 · 0 评论