Skip to main content

๐ŸŽฎ Sliding Window (Practice)

Companion to the Sliding Window guide. Watch the window slide and reuse its sum in O(1), then implement it.

๐ŸŽฌ Watch it workโ€‹

Max sum subarray of size kStep 1 / 5
2
1
5
1
3
2
First window (size 3) sum = 8

๐Ÿ Your turnโ€‹

Loading editorโ€ฆ

๐Ÿง  Challenge yourselfโ€‹

  1. Return the starting index of the best window, not just the sum.
  2. Switch to a variable-size window: smallest subarray with sum โ‰ฅ target.
  3. Longest substring without repeating characters โ€” why is a window ideal?

Continue the path โ†’ Binary Search