Variable Window with Two Pointers
Grow and shrink to meet a condition.
When the Window Breathes
Some problems do not fix the window length. Instead the window grows and shrinks to keep a condition true, like a sum staying under a limit.
Two Pointers, One Window
Keep two indices, left and right, marking the window edges. The right pointer expands while left trails behind to shrink when needed.
left = 0
window = 0All lessons in this course
- Fixed-Size Window Sums
- Variable Window with Two Pointers
- Longest Substring Without Repeats
- Count Windows That Satisfy a Rule