AAlgoLoopSpaced repetition for LeetCode

Sliding Window

A sliding window keeps a contiguous range over an array or string and expands or shrinks its two edges to maintain a constraint, turning an O(n²) scan of every subarray into a single O(n) pass. Use it for longest / shortest / contains questions about a contiguous subarray or substring.

15 LeetCode problems solved with the Sliding Window pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →