另一个pointer tack在某个关建数位置,比如说nums[i]=0
或者左pointer,取一个范围, 像minimum window
Ex:
» 283. Mover Zeros F家Bloomberg
http://rainykat.blogspot.com/2016/12/leetcodefacebook-move-zeroes.html
» 26.80. Remove Duplicates from Sorted Array 各大家
http://rainykat.blogspot.com/2017/01/leetcode-2680-remove-duplicates-from.html
➭ Window & Find Substring with restriction
window is subarray nums[i,j] two while loop to control move of i & j only forwards
» 209. Minimum Size Subarray Sum F家
http://rainykat.blogspot.com/2017/01/leetcodef-209-minimum-size-subarray.html
» 3. Longest Substring Without Repeating Characters(HashMap+2 pointer) 各大家
http://rainykat.blogspot.com/2017/01/leetcode-3-longest-substring-without.html
» 159. Longest Substring with At Most Two Distinct Characters G家
http://rainykat.blogspot.com/2017/01/leetcodeg-159-longest-substring-with-at.html
» 76. Minimum Window Substring 各大家
http://rainykat.blogspot.com/2017/01/leetcode-76-minimum-window-substring.html
» 438. Find All Anagrams in a String 亚麻
http://rainykat.blogspot.com/2017/01/leetcode-438-find-all-anagrams-in.html
2.一个pointer从头走
一个pointe从尾走
判断条件while(start<end),也不一定
Ex:
» 125. Valid Palindrome 各大家
http://rainykat.blogspot.com/2016/12/leetcodef-valid-palindrome.html
» 344.345. Reverse Vowels of a String G家
http://rainykat.blogspot.com.tr/2017/01/leetcodeg-344345-reverse-vowels-of.html
» 75. Sort color(找adjacent #)F家,微软,pocket gems
http://rainykat.blogspot.com/2017/01/leetcodef-75-sort-colorstwo-pointer.html
» 167. Two Sum II - Input array is sorted(two pointer) 亚麻
» 27.Remove element (尾巴在减少) https://leetcode.com/problems/remove-element/
» 15. 3sum(3 poniter)各大家
i (0-len-2)for loop, while loop -- j(i+1),k(len-1)(j<k)3ptr
http://rainykat.blogspot.com/2017/01/leetcode-3sum3-poniter.html» 16. 3Sum Closest(3 ptr) Bloomberg
http://rainykat.blogspot.com/2017/01/leetcodebloomberg-16-3sum-closest3-ptr.html
» 259. 3Sum Smaller (3 ptr) G家
http://rainykat.blogspot.com/2017/01/leetcodeg-259-3sum-smaller-3-ptr.html
3.两个Array比较
if nums1[i]<nums2[j]{i++;}
else if nums1[i]>nums2 {j++;}
else{//相等情况
i++;j++;
}
Ex
1.找intersection
https://leetcode.com/problems/intersection-of-two-arrays/
No comments:
Post a Comment