diff --git a/problems/0053.最大子序和.md b/problems/0053.最大子序和.md index b8b11a57..436e763b 100644 --- a/problems/0053.最大子序和.md +++ b/problems/0053.最大子序和.md @@ -160,7 +160,19 @@ class Solution { ``` Python: - +```python +class Solution: + def maxSubArray(self, nums: List[int]) -> int: + result = -float('inf') + count = 0 + for i in range(len(nums)): + count += nums[i] + if count > result: + result = count + if count <= 0: + count = 0 + return result +``` Go: