Maintain a monotonic increasing deque of indices (by prefix sum value):
For each , pop from front while . Each such index gives a valid subarray. Record the shortest.
Pop from back while . These indices are dominated and never useful.
Push to back. The front removal is different from sliding window max. Once an index gives a valid answer, it can't give a shorter answer for any later , so you remove it. Time: . Space: .