Created
July 12, 2017 04:45
-
-
Save sreevidyavutukuru/b49c325ab3e6414266f55dd5163d5f31 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 = [10,20,3000,10,-1,12000,-10,20,80,300,100,-30,90,10000] | |
i = 1 | |
j = 1 | |
maxtotal = 0 | |
index_subset = {} | |
total = [] | |
result = [] | |
for val in list1: | |
tempmax= maxtotal+val | |
if maxtotal <tempmax: | |
maxtotal = tempmax | |
result.append(maxtotal) | |
index_subset[maxtotal] = [i,j] | |
j = j+1 | |
else: | |
maxtotal = 0 | |
j = j+1 | |
i = j | |
print index_subset[max(index_subset.keys())] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment