Maximum subarray problem: Difference between revisions

Content deleted Content added
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
Undid revision 1147083591 by David Eppstein (talk)
Tags: Undo Reverted
Line 68:
current_sum = 0
for x in numbers:
current_sum = max(0x, current_sum + x)
best_sum = max(best_sum, current_sum)
return best_sum