Two Pointers
Two indices moving under an invariant. Converts nested loops into one pass.
Newinterview weight 8511 problems1 visualisers
18
mastery
Attempts logged
0
Predicted success on the next one
33%
Solved here
0 / 11
What you actually need to hold in your head
- Opposite ends for sorted pair problems
- Same direction for partitioning
- Fast and slow for cycles and midpoints
- Each pointer only moves forward, so O(n)
Watch it run
Step through the algorithm before you write it.
Patterns in this topic
The trigger phrases are what you are training yourself to notice.
Two Pointers problems
Ordered by sheet phase, so the early ones are the highest signal.
0 / 11 solved