class Solution {
public int minSubArrayLen(int target, int[] nums) {
int len = nums.length;
int begin = 0;
int end = 0;
int sum = 0;
int min = Integer.MAX_VALUE;
while(end < len){
sum += nums[end];
while (sum >= target) {
min = Math.min(min, end - begin + 1);
sum -= nums[begin];
begin++;
}
end++;
}
if(min == Integer.MAX_VALUE){
return 0;
}
return min;
}
}
02-25
190
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-29
3870
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)