mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0053.最大子序和.md
Added python version code
This commit is contained in:
@ -142,7 +142,19 @@ Java:
|
|||||||
|
|
||||||
|
|
||||||
Python:
|
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:
|
Go:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user