Created
July 2, 2019 04:53
-
-
Save athulmurali/fb1f516f38dcc30a628d5eefc33e98c6 to your computer and use it in GitHub Desktop.
KudaneMaxSum
This file contains 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: | |
local_sum = 0 | |
global_sum = -float("inf") | |
for i in nums: | |
local_sum = local_sum + i | |
if i >= local_sum: | |
local_sum = i | |
if local_sum > global_sum: | |
global_sum = local_sum | |
return global_sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment