```
int minSubArrayLen(int s, vector<int>& nums) {
int start = 0, end = 0, minLen = INT_MAX, sum = 0;
while (end <= nums.size()) {
if (sum >= s) {
minLen = min(minLen, end-start);
sum -= nums[start++];
}
else if (end < nums.size()) sum += nums[end++];
else break;
}
return minLen == INT_MAX? 0 : minLen;
}
```