Problem statement
You are given an array and allowed to remove at most one value from a chosen run. Return the largest total the run can reach.
The removed value has to sit inside the run, so the run stays contiguous apart from that single gap.
Examples
Input[1, -2, 0, 3]
Output4
Dropping the -2 leaves 1, 0 and 3.
Input[5, -10, 5]
Output10
Dropping the -10 puts both fives in one run.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing