Update 0053.最大子序和.md

Added python version code
This commit is contained in:
LiangDazhu 2021-05-12 23:19:18 +08:00 committed by GitHub
parent 4cbdfc079e
commit 9d00f80c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -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