patterns
20 min
sliding-window
two-pointers

Pattern: Sliding Window & Two Pointers

Shrink/expand windows and left/right scans on sorted arrays.

Covers: sliding-window · two-pointers

Sliding window Use when the answer is a **contiguous** subarray/substring with a property (sum, unique chars, coverage).

Expand–shrink 1. Expand `right` and update counters. 2. While valid (or invalid), shrink `left` and update best answer. 3. Careful with “at most / at least / exactly” wording.

Two pointers Sorted array pair sums, removing duplicates in-place, palindrome checks, merge of two sorted lists.

Practice Minimum Window Substring — explain the need-count vs have-count loop before coding.

Crucible — Interview prep with real proof