How can we get the indices of start and end of the subarray with largest sum ?
have a look at this:
def find_max_sum_sublist(lst):
# Write your code here!
global_max = float('-inf')
sums = {}
idxs = {}
start = 0
for idx, n in enumerate(lst):
sums[idx] = max(n, n+sums.get(idx-1, 0))
if n > n+sums.get(idx-1, 0):
start = idx
if sums[idx] > global_max:
global_max = sums[idx]
idxs[global_max] = start, idx+1
print(sums)
print(idxs)
return global_max
idxs of the max value is what you are looking for