雙指針 Two Pointers
40 題(29 題以此為主技法)
🎯 何時用
已排序陣列找配對/三數和,或從兩端往中間夾逼、原地分割。
🧩 模板心法
左右指針依大小關係內縮;或快慢同向指針做原地覆寫(移除、去重)。
Easy 16 題
- #125Valid Palindrome
- #88Merge Sorted Array
- #26Remove Duplicates From Sorted Array
- #27Remove Element
- #160Intersection of Two Linked Lists
- #283Move Zeroes
- #344Reverse String
- #392Is Subsequence
- #680Valid Palindrome II
- #977Squares of a Sorted Array
- #1768Merge Strings Alternately
- #141Linked List Cycle
- #202Happy Number
- #234Palindrome Linked List
- #876Middle of the Linked List
- #1984Minimum Difference Between Highest And Lowest of K Scores
Medium 22 題
- #11Container With Most Water
- #153Sum
- #19Remove Nth Node From End of List
- #31Next Permutation
- #75Sort Colors
- #184Sum
- #61Rotate List
- #80Remove Duplicates From Sorted Array II
- #86Partition List
- #189Rotate Array
- #763Partition Labels
- #838Push Dominoes
- #881Boats to Save People
- #1498Number of Subsequences That Satisfy The Given Sum Condition
- #1721Swapping Nodes in a Linked List
- #1968Array With Elements Not Equal to Average of Neighbors
- #2130Maximum Twin Sum Of A Linked List
- #5Longest Palindromic Substring
- #143Reorder List
- #647Palindromic Substrings
- #167Two Sum II - Input Array Is Sorted
- #658Find K Closest Elements