Maximum subarray problem: Difference between revisions

Content deleted Content added
m The code has a bug in it. It's supposed to reset the range to the new minimum value of it's current iteration. It was keeping it at zero.
Tag: Reverted
Undid revision 1147083417 by Onewikibarnes (talk) what part of "This version of the algorithm will return 0 if the input contains no positive elements (including when the input is empty)" do you not understand?
Tags: Undo Reverted
Line 68:
current_sum = 0
for x in numbers:
current_sum = max(x0, current_sum + x)
best_sum = max(best_sum, current_sum)
return best_sum