https://leetcode.com/problems/minimum-size-subarray-sum/

给定一个整形数组和一个数字s,找到数组中最短的一个连续子数组,使得连续子数组的数字和sum>=s,返回这个最短的连续子数组的长度值

class Solution {
    public int minSubArrayLen(int s, int[] nums) {
        int i = 0, j = -1, sum = 0, minLength = Integer.MAX_VALUE;
        while(i < nums.length){
            if(j + 1 < nums.length && sum < s){
                sum+=nums[++j];
            }else{
                sum-=nums[i++];
            }
            if(sum >= s){
                minLength = Math.min(j-i+1, minLength);
            }
        }
        if(minLength == Integer.MAX_VALUE){
            return 0;
        }
        return minLength;
    }
}