Problem
nums is circular: after the last element comes the first one again. Return the largest sum of a non-empty run of neighbouring elements. A run may wrap around the end, but it may use each element at most once.
Example 1
- Input
- nums = [1, -2, 3, -2]
- Output
- 3
- Why
- just [3]
Example 2
- Input
- nums = [5, -3, 5]
- Output
- 10
- Why
- 5, then wrap to 5
Example 3
- Input
- nums = [-3, -2, -3]
- Output
- -2
- Why
- you must take at least one
Constraints
n == nums.length1 <= n <= 3 * 10^4-3 * 10^4 <= nums[i] <= 3 * 10^4