Skip to content

Instantly share code, notes, and snippets.

@sreevidyavutukuru
Created July 12, 2017 04:45
Show Gist options
  • Save sreevidyavutukuru/b49c325ab3e6414266f55dd5163d5f31 to your computer and use it in GitHub Desktop.
Save sreevidyavutukuru/b49c325ab3e6414266f55dd5163d5f31 to your computer and use it in GitHub Desktop.
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