Medium
Quiz
#209 Minimum Size Subarray Sum
APPROACH
Given a positive integer target and an array of positive integers nums, return the minimum length of a contiguous subarray whose sum is at least target. If no such subarray exists, return 0.
Example 1:
Input: target = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: The subarray [4,3] has the minimal length under the problem constraint.
Example 2:
Input: target = 4, nums = [1,4,4]
Output: 1
Example 3:
Input: target = 11, nums = [1,1,1,1,1,1,1,1]
Output: 0
1 of 4
1:00
What is the optimal approach for this problem?