
3Sum
A reliable 3Sum solution comes from turning a cubic search into a sequence of sorted two-sum scans—and proving why each pointer move is safe.
View solutionCoordinate two indices to shrink the search space in arrays, strings, and partitions.
Problems
Practice problems that share this primary solution pattern and compare the clues that reveal it.

A reliable 3Sum solution comes from turning a cubic search into a sequence of sorted two-sum scans—and proving why each pointer move is safe.
View solution
The target does not identify the winning triplet. It tells each pointer which direction is still worth exploring.
View solution
Four choices suggest an O(n^4) search. Sorting changes the last two choices into a controlled walk.
View solution
The hard part is not calculating width × shorter_height. It is proving why one whole family of pairs can be discarded without checking them.
View solution
The word “remove” is misleading here. You do not need to shrink the Python list or delete values from its tail. You need to compact the distinct values…
View solution
The array is not shortened. The judge inspects only a prefix, so the job is to compact the values you keep into that prefix and return its length.
View solution
A left-to-right merge can overwrite values in nums1 before you have compared them. The reliable Merge Sorted Array solution uses backward two pointers:…
View solution
The trap is treating duplicate removal as a counting problem. The sharper model is an input stream and a compacted result prefix: read every candidate,…
View solution
The trap in the Sort Colors solution is assuming that “only three values” makes the problem trivial. Counting works. The interview version asks you to see…
View solution
The picture suggests moving inward from both ends. The proof requires more: finalize only the side whose limiting boundary is already certified.
View solution