Maximum subarray problem: Difference between revisions

Content deleted Content added
fixups
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
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