Week 2 · Day 9 of 42
Sliding Window: Variable Size and Character Frequency Matching
If the problem says "longest/shortest subarray/substring satisfying some condition" — use a variable-size sliding window. Expand right to include, shrink left when the condition breaks. If the problem involves anagrams, permutations in a string, or matching character frequencies between a window and a target — use a frequency-counting sliding window with a "matched" counter.
Checking access
Spotted a mistake on this page?
Wrong formula, broken animation or confusing wording. Tell us and we will fix it.