public int minSubArrayLen2(int s, int[] nums) {
		if (nums.length == 0)
			return 0;

		int[] sums = new int[nums.length];
		sums[0] = nums[0];
		for (int i = 1; i < nums.length; i++) {
			sums[i] = sums[i - 1] + nums[i];
		}
		if (sums[nums.length - 1] < s)
			return 0;

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < nums.length; i++) {
			int l = i;
			int r = nums.length - 1;
			while (l <= r) {
				int mid = l + (r - l) / 2;
				if (sums[mid] - sums[i] + nums[i] == s) {
					l = mid;
					break;
				} else if (sums[mid] - sums[i] + nums[i] < s) {
					l = mid + 1;
				} else {
					r = mid - 1;
				}
			}
			if (l >= sums.length)
				break;
			ans = Math.min(ans, l - i + 1);
		}

		return (ans == Integer.MAX_VALUE ? 0 : ans);
	}