Shortest Sufficient Stretch — Solution & Editorial
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)
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)