```
public int minSubArrayLen(int s, int[] nums) {
if(nums.length==0) return 0;
int p1=0, sum=0, min=nums.length;
boolean possible=false;
for(int i=0; i<nums.length; i++){
sum+=nums[i];
while(sum-nums[p1]>=s){
sum-=nums[p1++];
}
if(sum>=s&&i-p1<min){
min=i-p1;
possible=true;
}
}
return possible? min+1: 0;
}
```