Variable-size windows grow and shrink based on a condition. The pattern is:
Expand: move forward, adding the new element to the window.
Shrink: while the window violates some constraint, move forward, removing elements.
Update: after each expansion, update your answer. Here's the trick: each element is added once and removed at most once. Even though there's a nested loop, total work is .