nums contains positive whole numbers. Return the length of the shortest contiguous subarray whose sum is at least target, or 0 if there is none.
For target = 7 and nums = [2, 3, 1, 2, 4, 3] the answer is 2 ([4, 3]).
The starter code tries every start. It is correct but too slow for long lists.
Example 1
Input:
min_subarray_len(7, [2, 3, 1, 2, 4, 3])
Output:
2
Example 2
Input:
min_subarray_len(4, [1, 4, 4])
Output:
1
0 <= len(nums) <= 2000001 <= nums[i] <= 10**41 <= target <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.