diff --git a/problems/0053.最大子序和.md b/problems/0053.最大子序和.md index b8a9d748..f5526a61 100644 --- a/problems/0053.最大子序和.md +++ b/problems/0053.最大子序和.md @@ -145,7 +145,20 @@ Python: Go: - +```go +func maxSubArray(nums []int) int { + maxSum := nums[0] + for i := 1; i < len(nums); i++ { + if nums[i] + nums[i-1] > nums[i] { + nums[i] += nums[i-1] + } + if nums[i] > maxSum { + maxSum = nums[i] + } + } + return maxSum +} +```