Lesson 184
Two Pointers
Converge · Fast & Slow · Slide
1:00How to replace O(n²) pair-checks with a single O(n) pass by maintaining two index variables that move under a rule — converging, fast-and-slow, or same direction.
By the end, you can
- Explain why converging two pointers on a sorted array is safe and never skips a valid pair.
- Trace the move rule for a pair-sum problem: identify which pointer moves and why when the current sum is too small or too big.
- Trace Floyd's tortoise-and-hare algorithm and explain why fast is guaranteed to land exactly on slow inside a cycle.
- Implement same-direction dedup: identify which elements the write pointer copies and what the return value represents.
- Describe the sliding-window mechanic: explain when right expands the window, when left shrinks it, and why both pointers only ever move forward.
- State the big-O time and space complexity of two pointers versus brute force.
- Choose the correct two-pointer flavor (converging, fast/slow, same direction) for a given problem.
Up next in Coding Interview Patterns




