Merge pull request #52 from LiangDazhu/master

添加 0053.最大子序和 Python版本
This commit is contained in:
Carl Sun 2021-05-13 10:33:27 +08:00 committed by GitHub
commit ce6036329e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

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