A ring road has n stops in a circle; stops[i] is the profit (possibly negative) earned by serving stop i. A route serves a non-empty contiguous run of stops around the ring, so it may wrap from the last stop back to the first, but it may not visit any stop twice. Return the maximum total profit of a single route.
Examples
Input: stops = [5, -3, 5]
Output: 10
Explanation: Serve the last stop, wrap around, and serve the first stop.
Input: stops = [-2, -3, -1]
Output: -1
Constraints
1 <= len(stops) <= 10**5,-10**4 <= stops[i] <= 10**4.- Target complexity: O(n) time, O(1) extra space.
Goals
- Reduce the wrap-around case to the complement of a minimum subarray
- Combine the ordinary and wrapped answers, guarding the all-negative case