We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f03f8d2 + af1b3e3 commit 648833eCopy full SHA for 648833e
problems/0209.长度最小的子数组.md
@@ -448,6 +448,27 @@ object Solution {
448
}
449
450
```
451
-
+C#:
452
+```csharp
453
+public class Solution {
454
+ public int MinSubArrayLen(int s, int[] nums) {
455
+ int n = nums.Length;
456
+ int ans = int.MaxValue;
457
+ int start = 0, end = 0;
458
+ int sum = 0;
459
+ while (end < n) {
460
+ sum += nums[end];
461
+ while (sum >= s)
462
+ {
463
+ ans = Math.Min(ans, end - start + 1);
464
+ sum -= nums[start];
465
+ start++;
466
+ }
467
+ end++;
468
469
+ return ans == int.MaxValue ? 0 : ans;
470
471
+}
472
+```
473
-----------------------
474
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
0 commit comments