Skip to content

Instantly share code, notes, and snippets.

@Desolve
Created July 2, 2019 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Desolve/37fa93e5c41056d82306906bee93ad2d to your computer and use it in GitHub Desktop.
Save Desolve/37fa93e5c41056d82306906bee93ad2d to your computer and use it in GitHub Desktop.
0053 Maximum Subarray
class Solution:
def maxSubArray(self, nums: 'List[int]') -> 'int':
l = len(nums)
if l == 0: return 0
res = now = nums[0]
for i in range(1, l):
if now > 0:
now += nums[i]
else:
now = nums[i]
if now > res:
res = now
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment