Problem statement
You are given an array and told to treat it as a ring: a run may take a tail and a head at once. Return the largest total of any run, with at least one value in it.
Every value can be negative, so the answer is not automatically positive, and a wrapped candidate that removes everything is not a valid run.
Examples
Input[5, -10, 5]
Output10
The two fives wrap around the -10 and total 10.
Input[-3, -1, -2]
Output-1
Every value is negative, so the answer is the least negative single value.
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