All Categories

Two Pointers

Two pointers reduce O(n²) to O(n) on sorted data.

Use two indices from opposite ends or same direction.

Move pointers based on comparison with target.

Key Concepts

Opposite Direction

Left at 0, right at end

Same Direction

Slow/fast pointer patterns

Problems (18)