```
class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
int n = nums.size();
int result = n + 1;
int left = 0;
int right = 0;
int sum = 0;
while(right < n)
{
sum = sum + nums[right];
right = right + 1;
while(sum >= s)
{
result = min(result, right-left);
sum = sum - nums[left];
left = left + 1;
}
}
if(result == n+1)
return 0;
else
return result;
}
};
```