two_pointers

011.Container-With-Most-Waterarrow-up-right (M+) 015.3Sumarrow-up-right (M) 016.3Sum-Closetarrow-up-right (M) 018.4Sumarrow-up-right (M) 259.3Sum-Smallerarrow-up-right (M+) 030.Substring-with-Concatenation-of-All-Wordsarrow-up-right (H) 075.Sort-Colorsarrow-up-right (M+) 026.Remove Duplicates from Sorted Arrayarrow-up-right (H-) 080.Remove Duplicates from Sorted Array IIarrow-up-right (H) 209.Minimum-Size-Subarray-Sumarrow-up-right (M) 088.Merge Sorted Arrayarrow-up-right (M) 283.Move-Zeroesarrow-up-right (M) 141.Linked-List-Cyclearrow-up-right (E+) 142.Linked-List-Cycle-IIarrow-up-right (M+) 360.Sort-Transformed-Arrayarrow-up-right (M) 713.Subarray-Product-Less-Than-Karrow-up-right (M+) 923.3Sum-With-Multiplicityarrow-up-right (H-) 1234.Replace-the-Substring-for-Balanced-Stringarrow-up-right (H-) 1498.Number-of-Subsequences-That-Satisfy-the-Given-Sum-Conditionarrow-up-right (H-) 1574.Shortest-Subarray-to-be-Removed-to-Make-Array-Sortedarrow-up-right (H-) 1687.Delivering-Boxes-from-Storage-to-Portsarrow-up-right (H) 1793.Maximum-Score-of-a-Good-Subarrayarrow-up-right (M+)

Sliding window

532.K-diff-Pairs-in-an-Arrayarrow-up-right (H-) 611.Valid-Triangle-Numberarrow-up-right (M+) 1004.Max-Consecutive-Ones-IIIarrow-up-right (M) 1052.Grumpy-Bookstore-Ownerarrow-up-right (M) 1838.Frequency-of-the-Most-Frequent-Elementarrow-up-right (H-) 395.Longest-Substring-with-At-Least-K-Repeating-Charactersarrow-up-right (H) 1763.Longest-Nice-Substringarrow-up-right (H)

Begin and end type

  • example problems: two sum (sorted), three sum, four sum, three sum closest, three sum smaller

  • Example problem: KSum

Greedy

Partition type

  • example problems: two sum (sorted), three sum, four sum, three sum closest, three sum smaller

Slow and fast

  • Find the middle of linked list

  • Find linked list cycle

Window type

  • Improve naive two level for loop to for-outer loop + while inner loop

  • E.g. minimum window substring, minimum size subarray sum, Longest substring with at most K distinct characters, Longest substring without repeating characters

Sliding window : Distinct Characters

076.Minimum-Window-Substringarrow-up-right (M+) 003.Longest-Substring-Without-Repeating-Characterarrow-up-right (E+) 159.Longest-Substring-with-At-Most-Two-Distinct-Charactersarrow-up-right(H-) 340.Longest-Substring-with-At-Most-K-Distinct-Charactersarrow-up-right (H) 992.Subarrays-with-K-Different-Integersarrow-up-right (H-)

Two pointers for two seuqences

986.Interval-List-Intersectionsarrow-up-right (M) 1229.Meeting-Schedulerarrow-up-right (M+) 1537.Get-the-Maximum-Scorearrow-up-right (H-) 1577.Number-of-Ways-Where-Square-of-Number-Is-Equal-to-Product-of-Two-Numbersarrow-up-right (H-) 1775.Equal-Sum-Arrays-With-Minimum-Number-of-Operationsarrow-up-right (M+) 1868.Product-of-Two-Run-Length-Encoded-Arraysarrow-up-right (M+)

Last updated