Two Pointers Practice Questions
Ten interview classics, every flavor represented. Each problem is a direct instance of one of the opposite-ends, same-direction, or fast-and-slow templates — once you spot which flavor it is, the code writes itself.
Before reading any solution, force yourself through the four-question checklist:
- Which flavor? (Opposite-ends / same-direction / fast-and-slow)
- What does each pointer represent?
- What’s the movement rule?
- When do I stop?
The code is six to ten lines. The whole chapter.
Easy
| Problem | Pattern | Status |
|---|---|---|
| Two Sum II — Input Array Is Sorted | Opposite-ends, classic convergence | Available |
| Valid Palindrome | Opposite-ends with skip-junk inner loop | Available |
| Remove Duplicates from Sorted Array | Same-direction read/write | Available |
| Squares of a Sorted Array | Opposite-ends, fill from the back | Available |
Medium
| Problem | Pattern | Status |
|---|---|---|
| 3Sum | Sort + fix one + two-pointer + dedup | Available |
| Container With Most Water | Opposite-ends, move the shorter side | Available |
| Sort Colors | Three-pointer Dutch national flag | Available |
| Linked List Cycle II | Floyd’s + reset + same-speed pass | Available |
| Find the Duplicate Number | Array as linked list + Floyd’s | Available |
Hard
| Problem | Pattern | Status |
|---|---|---|
| Trapping Rain Water | Opposite-ends with running max on each side | Available |
More Practice (Coming Soon)
| Problem | Pattern | Status |
|---|---|---|
| 4Sum | K-Sum reduction | Coming Soon |
| 3Sum Closest | 3Sum with min-distance tracking | Coming Soon |
| Remove Duplicates from Sorted Array II | Same-direction with “allow 2 of each” | Coming Soon |
| Boats to Save People | Opposite-ends greedy pairing | Coming Soon |
| Merge Sorted Array (in place) | Right-to-left two-pointer | Coming Soon |
| Backspace String Compare | Two-pointer from the right | Coming Soon |
| Longest Word in Dictionary | Two-pointer subsequence matching | Coming Soon |
| Palindrome Linked List | Find middle + reverse + compare | Coming Soon |
| Happy Number | Floyd’s cycle on digit-square-sum | Coming Soon |
| Move Zeroes | Same-direction read/write | Coming Soon |