Running Optimum
Keep the best candidate ending here and the best seen globally.
Recognition signal
A choice can extend yesterday’s candidate or start afresh.
Method
Compare extending the old candidate with starting at the current value.
Worked example
In [−5, 4, −1, 3], the final best ending here is 6.
Common mistake
Initializing the best to zero invents an empty answer when a nonempty answer is required.