Skip to content

Two Pointers & Sliding Window

Two Pointers is a technique where we maintain two indices (often l and r) that move over the array or string.
Sliding Window is a special case applied to contiguous subarrays: we expand with one pointer, and contract with the other, depending on constraints.

This transforms many naive solutions into or with proper data structures.


Resources


Videos