← Back

Two Pointer Technique

Maintain two indices moving towards condition satisfaction (sorted or window problems).

arraystwo-pointerstechniqueUpdated 2025-09-01

Patterns

  • Opposite ends: sum target (sorted)
  • Same direction: shrink/expand window

Benefits

  • Reduce O(n^2) nested loops to O(n)