Last active
May 20, 2020 03:07
-
-
Save vadik49b/9bb9089753ffc4fa9498cd1d92ed01e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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