Problems > Shortest Sufficient Stretch > Editorial

Shortest Sufficient Stretch — Solution & Editorial

Back to the Problem

Expand right; while the window sum still reaches K, record the length and shrink from the left. Works because all values are positive.

Complexity: O(N)