13. Shortest Subarray with Sum at Least K (Negative Numbers)
Return the length of the shortest, non-empty, contiguous subarray of A
with sum at least K
.
If there is no non-empty subarray with sum at least K
, return -1
.
Example 1:
Example 2:
Example 3:
Solution: (Prefix Sum + Deque)
Explanation:
Time Complexity: O(n)
Last updated