Shortest Subarray With Sum at Least K
Hard
Monotonic Deque
Print the length of the shortest non-empty contiguous subarray whose sum is at least K, or -1 if none exists. The array may contain negative numbers.
Constraints
1 <= n <= 10^5 -10^5 <= nums[i] <= 10^5 1 <= K <= 10^9
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.