Small example with negatives
Input
nums = [2, -1, 2], k = 3
Output
3
The whole array sums to 3, length is 3.
Full lesson preview
Find the minimal-length contiguous subarray whose sum is >= k (supports negative numbers).
Problem statement
Task
Examples
Input
nums = [2, -1, 2], k = 3
Output
3
The whole array sums to 3, length is 3.
Input format
Output format
Constraints
Samples
Input
nums = [1, 2, 3, 4, 5], k = 11
Output
3
Subarray [3,4,5] sums to 12 and is minimal length 3.