Created
August 10, 2017 03:34
-
-
Save sreevidyavutukuru/5a00505a49906caf23924b1fb3bcea1a to your computer and use it in GitHub Desktop.
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
list1 = [-2,-1,4,-1,-2,1,5,-3] | |
def maxsum(list1): | |
if list1 != None: | |
max_so_far = list1[0] | |
max_here = list1[0] | |
for val in list1[1:]: | |
max_here = max_here + val | |
if max_here> max_so_far : | |
max_so_far = max_here | |
if max_here <0: | |
max_here = 0 | |
return max_so_far | |
print maxsum(list1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi sreevidyavutukuru,
I am new to Gist. I am wondering how can I type in python code.
'''python
if a is None:
return True
'''
Unfortunately, this didn't work.