You are given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.
A subarray is a contiguous non-empty sequence of elements within an array.
Example 1:
Input: target = 10, nums = [2,1,5,1,5,3]
Output: 3Explanation: The subarray [5,1,5] has the minimal length under the problem constraint.
Example 2:
Input: target = 5, nums = [1,2,1]
Output: 0Constraints:
1 <= nums.length <= 100,0001 <= nums[i] <= 10,0001 <= target <= 1,000,000,000Follow up: If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log(n)).