Longest Substring with At Most K Distinct Characters
This is a core variable-size sliding window problem. The constraint of at most k distinct characters drives the shrink condition — a pattern that generalizes to many "at most K" problems in strings and arrays.
Enable JavaScript for the full StreamPrep guide.