```
public class Solution {
public int MinSubArrayLen(int s, int[] nums) {
int n=nums.Length;
int start=0,end=0,sum=s,min=int.MaxValue;
while(end<n)
{
sum -= nums[end];
while(sum<=0)
{
min=Math.Min(end-start+1,min);
sum+=nums[start];
start++;
}
end++;
}
if(min==int.MaxValue)
return 0;
return min;
}
}
```