Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead.

&nbsp;
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


&nbsp;
Constraints:


	1 &lt;= target &lt;= 109
	1 &lt;= nums.length &lt;= 105
	1 &lt;= nums[i] &lt;= 104


&nbsp;
Follow up: If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log(n)).
class Solution:
    def minSubArrayLen(self, target, nums):
		# Init left pointer and answer
        l, ans = 0, len(nums) + 1
		# Init sum of subarray
        s = 0 
		# Iterate through all numbers as right subarray 
        for r in range(len(nums)):
			# Add right number to sum
            s += nums[r]
			# Check for subarray greater than or equal to target
            while s >= target:
				# Calculate new min
                ans = min(ans, r - l + 1)
				# Remove current left nubmer from sum
                s -= nums[l]
				# Move left index up one
                l += 1
		# No solution
        if ans == len(nums) + 1:
            return 0
		# Solution
        return ans 
class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0;
        int n = nums.length;
        int sum = 0;
        int minCount = Integer.MAX_VALUE;
        for(int i = 0;i<n;i++){
            sum += nums[i];
            while(sum >= target){
                minCount = Math.min(minCount, i-left+1);
                sum -= nums[left++];
            }   
        }
        return minCount == Integer.MAX_VALUE?0:minCount;
    }
}
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int m=INT_MAX,s=0,l=0;
        for(int i=0;i<nums.size();i++)
        {
            s+=nums[i];
            if(s>=target)
                m=min(m,i-l+1);
            while(s>=target)
            {
                m=min(m,i-l+1);
                s-=nums[l++];
            }
        }
        if(m==INT_MAX)
            m=0;
        return m;
    }
};
/**
 * @param {number} target
 * @param {number[]} nums
 * @return {number}
 */
var minSubArrayLen = function(target, nums) {
    let indexStartPosition = 0;
    let sum = 0;
    let tempcounter = 0;
    let counter = Infinity;

    for(var indexI=0; indexI<nums.length; indexI++){
           sum = sum + nums[indexI];
        tempcounter++;

        while(sum >= target) {
           sum = sum - nums[indexStartPosition];
           indexStartPosition = indexStartPosition + 1;
           counter = Math.min(counter, tempcounter);
           tempcounter--;
        }

    }

    return counter === Infinity ? 0 : counter;
};
Minimum Size Subarray Sum