public static int minSubArrayLen(int s, int[] nums) {
		if (nums == null || nums.length == 0)
			return 0;

		int bt, ed, minLen, sum;

		// initial variable
		bt = ed = 0;
		minLen = Integer.MAX_VALUE;
		sum = nums[0];

		// slide window algorithm
		while ((ed < nums.length || sum >= s) && bt <= ed) {
			if (sum < s) {
				ed++;
				if (ed < nums.length)
					sum += nums[ed];
			} else {
				int tLen = ed - bt + 1;
				if (tLen < minLen) {
					minLen = tLen;
				}

				sum -= nums[bt++];
			}
		}

		return minLen == Integer.MAX_VALUE ? 0 : minLen;
	}