We’re preparing your current view and syncing the latest data.
Given an array of positive integers nums and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.
An integer s and an array of positive integers nums.
An integer representing the minimal length of a contiguous subarray such that the sum is at least s. Return 0 if no such subarray exists.
1 <= nums.length <= 10^5, 1 <= nums[i] <= 10^4, 1 <= s <= 10^9
Example 1
Input
s = 7, nums = [2,3,1,2,4,3]
Output
2
Explanation
The subarray [4,3] has the minimal length under the problem constraint.