Problems > Longest Affordable Streak > Editorial

Longest Affordable Streak — Solution & Editorial

Back to the Problem

Classic shrink-expand window: extend right, and while the sum exceeds K advance left. Positivity makes the window monotone.

Complexity: O(N)