Sliding Window (Restarting Window)
ProUse when the valid window must be contiguous and uninterrupted, and encountering a “bad” element means the window cannot be fixed by shrinking—you must reset.
Keywords for identifying Restarting Window Problems
→ “longest consecutive …”
→ “contiguous segment with no X”
→ “reset when you hit a X”
→ “breaks the streak”
Unlock the Sliding Window (Restarting Window) template
Get the full code template and worked LeetCode examples for Sliding Window (Restarting Window) — plus every other pattern in the library — with a one-time $29 lifetime upgrade.
Upgrade to ProSee free Binary Search template →