class Solution {
public int minSubArrayLen(int target, int[] nums) {
int sum = 0;
int min = nums.length+1;
int i = 0,j = 0;
if (nums.length==0) {
return 0;
}
while (i<nums.length) {
sum += nums[i];
i++;
while (sum>=target) {
min = Math.min(min, i-j);
sum -= nums[j];
j++;
}
}
if (min == nums.length+1) {
return 0;
}
else {
return min ;
}
}
}