```
public int minSubArrayLen(int s, int[] nums) {
if (nums == null || nums.length == 0) return 0;
int minL = Integer.MAX_VALUE;
int left = 0;
int right = 0;
while (right < nums.length) {
s -= nums[right];
while (s <= 0) {
minL = Math.min(minL, right - left + 1);
s += nums[left];
left ++;
}
right ++;
}
return minL == Integer.MAX_VALUE ? 0 : minL;
}
```