```
public int MinSubArrayLen(int s, int[] nums) {
int i = 0, j = 0, minLen = int.MaxValue;
int sum = 0;
while(j < nums.Length) {
while(j < nums.Length && sum < s) sum += nums[j++];
while(i < j && sum >= s) {
minLen = Math.Min(minLen, j - i);
sum -= nums[i];
i++;
}
}
return minLen == int.MaxValue? 0 : minLen;
}
```