209 Minimum Size subarray sum
public class Solution { public int minSubArrayLen(int s, int[] nums) { if (nums == null || nums.length == 0) { return 0; } int len = nums.length; int start = 0; int end= 0; int min_Len = len + 1; int sum = 0; while (end < len) { while (sum < s && end < len ) { sum += nums[end]; end++; } while (sum >= s && start < end) { if (end - start < min_Len) { min_Len = end - start; } sum -= nums[start]; start++; } } return min_Len < len+1 ? min_Len : 0; } }