🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 24 - Sliding WindowPractice QuestionsOverview

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:

  1. Contiguous range?
  2. Property monotone in window growth?
  3. Running state? (sum, count, hash map, deque)
  4. Slide rule (fixed) or shrink rule (variable)?
  5. When do I record the answer?

Five questions. Ten lines of code. The whole chapter.

Easy

ProblemPatternStatus
Max Consecutive Ones IIIVariable-size window with a “K zeros allowed” budgetAvailable
Find All Anagrams in a StringFixed-size window + match counterAvailable

Medium

ProblemPatternStatus
Longest Substring Without Repeating CharactersVariable-size, longest validAvailable
Minimum Size Subarray SumVariable-size, shortest validAvailable
Longest Substring with At Most K Distinct CharactersVariable-size, longest valid + frequency mapAvailable
Permutation in StringFixed-size + match counterAvailable
Longest Repeating Character ReplacementVariable-size, longest valid, with the “max freq” trickAvailable

Hard

ProblemPatternStatus
Subarrays with K Different IntegersAt-most-K trick (twice)Available
Minimum Window SubstringVariable-size, shortest valid + match counterAvailable
Sliding Window MaximumFixed-size + monotonic dequeAvailable

More Practice (Coming Soon)

ProblemPatternStatus
Count Number of Nice SubarraysAt-most-K trick on odd countsComing Soon
Binary Subarrays With SumAt-most-K trick on binary sumsComing Soon
Fruit Into BasketsVariable-size with at most 2 distinct (the simpler cousin of K distinct)Coming Soon
Longest Continuous Subarray LimitTwo monotonic deques (max + min in window)Coming Soon
Substrings with Distinct CharactersVariable-size, more constraintsComing Soon
Substring with Concatenation of All WordsMulti-word sliding windowComing Soon
Replace the Substring for Balanced StringWindow-on-complement variantComing Soon
K Radius Subarray AveragesFixed-size averaging on every centered windowComing Soon