Intro

The two pointers technique explained.

Two pointers uses two indices to traverse a data structure, reducing time complexity from O(n2)O(n^2) to O(n)O(n).

The core insight: Instead of nested loops where the inner loop starts from scratch, move pointers based on the current state. Each pointer moves at most nn times, giving O(n)O(n) total.

I'll teach you three patterns: opposite direction (converging), same direction (fast and slow), and sorted array pairing. You'll learn when each applies and how to identify two-pointer problems in interviews.