Skip to content

Commit 18054c8

Browse files
committed
Update solution 053 [Python3]
1 parent 37432b7 commit 18054c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def maxSubArray(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
n=len(nums)
8+
if n == 1:
9+
return nums[0]
10+
res=[0]*n
11+
res[0]=nums[0]
12+
max0=nums[0]
13+
for i in range(1,n):
14+
res[i]=max(res[i-1]+nums[i],nums[i])
15+
max0=max(res[i],max0)
16+
return max0

0 commit comments

Comments
 (0)