Sliding Window
Last updated
What is Sliding Window?
The sliding window pattern is used when you need to find an optimal subarray or substring that satisfies some constraint. Instead of checking every possible subarray from scratch, you maintain a window with two pointers and update the result incrementally as the window expands or shrinks. Fixed-size windows are straightforward; variable-size windows require a clear rule for when to shrink from the left. This stage also introduces the monotonic deque, which extends sliding window to problems that need the maximum or minimum within the window at each step.
Free resources to learn Sliding Window
More in stage 8: Sliding Window
Sliding Window: common questions
Can I learn Sliding Window in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Sliding Window in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Sliding Window tutorial for beginners?
It is lesson 40 of 137 in the free LeetCode roadmap, in stage 8, Sliding Window. If you are new to LeetCode, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.