11/40
Part 2 of 7 · Two statesLearn and do

A sum can also start over, and that rule is Kadane's algorithm

The same two rows work for the largest sum after one deletion, but a sum needs one choice that run lengths didn't. A length always grows when the run goes on. A sum can do better by starting over: if the best sum ending just before x is negative, x alone beats x added to it. So the best sum ending at x is the larger of x and x plus the best sum ending one before. That start-or-extend rule is Kadane's algorithm, and it fills the first row here.

In the editor, finish best_sum_one_out(xs): two rows for the largest sum after one deletion. It prints three sums.