public int minSubArrayLen_II(int s, int[] nums) {
        if (nums == null || nums.length == 0 || (nums.length == 1 && nums[0] < s)) {
            return 0;
        }
        int[] sum = new int[nums.length + 1];
        for (int i = 1; i < sum.length; ++i) {
            sum[i] = sum[i - 1] + nums[i - 1];
        }
        int len = Integer.MAX_VALUE;
        for (int i = 0; i < sum.length; ++i) {
            int end = binarySearch(i + 1, sum.length - 1, sum[i] + s, sum);
            if (end == sum.length)
                break;
            if (end - i < len)
                len = end - i;
        }
        if (len == Integer.MAX_VALUE)
            return 0;

        return len;
    }