Skip to content

Commit 99633e9

Browse files
authored
Create 53-Maximum-Subarray.py
1 parent 66b2826 commit 99633e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

53-Maximum-Subarray.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def maxSubArray(self, nums: List[int]) -> int:
3+
res = nums[0]
4+
5+
total = 0
6+
for n in nums:
7+
total += n
8+
res = max(res, total)
9+
if total < 0:
10+
total = 0
11+
return res

0 commit comments

Comments
 (0)