Skip to content

Instantly share code, notes, and snippets.

@vadik49b
Last active May 20, 2020 03:07
Show Gist options
  • Save vadik49b/9bb9089753ffc4fa9498cd1d92ed01e2 to your computer and use it in GitHub Desktop.
Save vadik49b/9bb9089753ffc4fa9498cd1d92ed01e2 to your computer and use it in GitHub Desktop.
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
max_subarray_sum = nums[0]
sum = 0
for i in range(len(nums)):
sum = max(nums[i], sum + nums[i])
max_subarray_sum = max(max_subarray_sum, sum)
return max_subarray_sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment