public int minSubArrayLen(int s, int[] nums) {
        if (nums == null) return -1;

        int i = 0, j = 0, sum = 0, minLen = Integer.MAX_VALUE;
        while (j < nums.length) {
            sum += nums[j];
            while (sum >= s) {
                minLen = Math.min(minLen, j - i + 1);
                sum -= nums[i++];
            }
            ++j;
        }
        return minLen == Integer.MAX_VALUE ? 0 : minLen;
    }