diff --git a/problems/0053.最大子序和.md b/problems/0053.最大子序和.md index b8a9d748..05c08a66 100644 --- a/problems/0053.最大子序和.md +++ b/problems/0053.最大子序和.md @@ -142,7 +142,19 @@ Java: 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: