Sliding Window Practice Questions
Ten interview classics, every flavor of the pattern represented. Each problem is a direct instance of one of the fixed or variable templates, the at-most-K trick, or an advanced technique — once you spot which flavor it is, the code writes itself.
Before reading any solution, force yourself through the pattern-spotting checklist:
- Contiguous range?
- Property monotone in window growth?
- Running state? (sum, count, hash map, deque)
- Slide rule (fixed) or shrink rule (variable)?
- When do I record the answer?
Five questions. Ten lines of code. The whole chapter.
Easy
| Problem | Pattern | Status |
|---|---|---|
| Max Consecutive Ones III | Variable-size window with a “K zeros allowed” budget | Available |
| Find All Anagrams in a String | Fixed-size window + match counter | Available |
Medium
| Problem | Pattern | Status |
|---|---|---|
| Longest Substring Without Repeating Characters | Variable-size, longest valid | Available |
| Minimum Size Subarray Sum | Variable-size, shortest valid | Available |
| Longest Substring with At Most K Distinct Characters | Variable-size, longest valid + frequency map | Available |
| Permutation in String | Fixed-size + match counter | Available |
| Longest Repeating Character Replacement | Variable-size, longest valid, with the “max freq” trick | Available |
Hard
| Problem | Pattern | Status |
|---|---|---|
| Subarrays with K Different Integers | At-most-K trick (twice) | Available |
| Minimum Window Substring | Variable-size, shortest valid + match counter | Available |
| Sliding Window Maximum | Fixed-size + monotonic deque | Available |
More Practice (Coming Soon)
| Problem | Pattern | Status |
|---|---|---|
| Count Number of Nice Subarrays | At-most-K trick on odd counts | Coming Soon |
| Binary Subarrays With Sum | At-most-K trick on binary sums | Coming Soon |
| Fruit Into Baskets | Variable-size with at most 2 distinct (the simpler cousin of K distinct) | Coming Soon |
| Longest Continuous Subarray Limit | Two monotonic deques (max + min in window) | Coming Soon |
| Substrings with Distinct Characters | Variable-size, more constraints | Coming Soon |
| Substring with Concatenation of All Words | Multi-word sliding window | Coming Soon |
| Replace the Substring for Balanced String | Window-on-complement variant | Coming Soon |
| K Radius Subarray Averages | Fixed-size averaging on every centered window | Coming Soon |