def find_max_sum_subarray(lst):
if (len(lst) < 1):
return 0;curr_max = lst[0];
global_max = lst[0];
length_array = len(lst);
for i in range(length_array):
if curr_max < 0:
curr_max = lst[i]
else:
curr_max += lst[i]
if global_max < curr_max:
global_max = curr_maxreturn global_max;
lst = [25, 2, -5, 1, 2, 3, 6, -5, 1];
print("Sum of largest subarray: ", find_max_sum_subarray(lst));
Above code is mentioned in the solution. But it does not work for the test case I have mentioned above. It is giving me answer as 59 where as real answer should be 30.