16 two pointers - other

这个又分几种类型。具体模板参照附录。

同向的:

sliding window

27 Remove Element

26 Remove Duplicate from Sorted Array

80 Remove Duplicate from Sorted Array II

283 Move Zeros

28 Implement strStr()

L521 Remove Duplicate Numbers in Array

485 Max Consecutive Ones

487 Max Consecutive Ones II -- 这题做的时候就寻思着会不会有flip k个的,然后果然有了

1004 Max Consecutive Ones III -- 一开始还以为是dp,然而还是slliding windows

243 Shortest Word Distance

244 Shortest Word Distance II

245 Shortest Word Distance III

Shortest Word Distance follow up -- 如果找3个的shortest distance 怎么找?这又让人联想到k个了...无穷无尽呀

1437 Check If All 1's Are at Least Length K Places Away -- 感觉跟28 brute force有一点点像

L1870 Number of Substrings with All Zeroes

2511 Maximum Enemy Forts That Can Be Captured

1089 Duplicate Zeros

1855 Maximum Distance Between a Pair of Values

795 Number of Subarrays with Bounded Maximum

对撞型:

2,3,4 Sum

344 Reverse String

11 Container With Most Water

42 Trapping Rain Water

125 Valid Palindrome

680 Valid Palindrome II

977 Squares of a Sorted Array

LinkedList 的快慢指针:

141 Linked List Cycle

142 Linked List Cycle II

234 Palindrome Linked List

19 Remove Nth Node From End of List

61 Rotate List

在两个数组上的和sorting类的:

merge sort

349 Intersection of Two Arrays

350 Intersection of Two Arrays II

L387 The Smallest Difference

Quick Sort + Partition 类

other related :

360 Sort Transformed Array

487 Max Consecutive Ones II

L406 Minimum Size Subarray Sum

L144 Interleaving Positive and Negative Numbers

L364 Trapping Rain Water II (407)

Last updated