using two pointers

```
class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
int len = nums.size();
if (len <= 0) return 0;
int minLen = len + 1;
int i = 0, j = 0, sum = 0;
while (j <= len)
{
if (sum >= s)
{
minLen = j - i < minLen ? j - i : minLen;
sum -= nums[i++];
}else
sum += nums[j++];
}
if (minLen == len + 1) // no solution
return 0;
else
return minLen;
}
};
```