Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 648833e

Browse files
authored
Merge pull request #1 from Cwlrin/Cwlrin-patch-1
添加(0209.长度最小的子数组.md):增加 C# 版本
2 parents f03f8d2 + af1b3e3 commit 648833e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

‎problems/0209.长度最小的子数组.md‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,27 @@ object Solution {
448448
}
449449
}
450450
```
451-
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+
```
452473
-----------------------
453474
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /