diff --git a/problems/0053.最大子序和.md b/problems/0053.最大子序和.md index 639c54bc..78c8b382 100644 --- a/problems/0053.最大子序和.md +++ b/problems/0053.最大子序和.md @@ -406,6 +406,26 @@ object Solution { } } ``` +### C# +**贪心** +```csharp +public class Solution +{ + public int MaxSubArray(int[] nums) + { + int res = Int32.MinValue; + int count = 0; + for (int i = 0; i < nums.Length; i++) + { + count += nums[i]; + res = Math.Max(res, count); + if (count < 0) count = 0; + } + return res; + } +} +``` +