Sliding window [mp]
Micro pattern¶
Description¶
Maintain a contiguous interval while moving its boundaries monotonically and preserving a validity condition.
Problems¶
Last-seen jump¶
Move the left boundary past the last occurrence of a repeated value.
- 3. Longest Substring Without Repeating Characters (Top Medium)
Frequency-constrained window¶
Shrink the left boundary as counts change to find a valid or optimal interval.
- 904. Fruit Into Baskets (Google Prep)
- 76. Minimum Window Substring (Top Hard)
Fixed-size window¶
Expire indices outside a fixed-width interval while retaining its best candidate.
- 239. Sliding Window Maximum (Top Hard)