two pointer
feeeeeeet
这个作者很懒,什么都没留下…
展开
-
Leetcode 16. 3Sum Closest
Extend from Leetcode 15class 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 · 106 阅读 · 0 评论 -
Leetcode 18. 4Sum
Extend from 3Sum. Add another for loop.Slow Versionclass 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 · 88 阅读 · 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 · 97 阅读 · 0 评论 -
Leetcode 75. Sort Colors
Two pointersleft points to the position that 0 endsright points to the position that 2 beginsclass Solution: def sortColors(self, nums): """ :type nums: List[int] :rtype...原创 2018-12-29 04:48:23 · 90 阅读 · 0 评论 -
Leetcode 80. Remove Duplicates from Sorted Array II
2 methodsclass Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 newT...原创 2018-12-30 09:35:30 · 99 阅读 · 0 评论