918. Maximum Sum Circular Subarray
Practice Maximum Sum Circular Subarray for free on NudgeCode: Medium, Greedy pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
nums is circular: after the last element comes the first one again. Return the largest sum of a non-empty subarray, where a subarray may wrap around the end but may use each element at most once.
Example
nums = [5,-3,5] -> 10 (5 + 5, wrapping around)
nums = [1,-2,3,-2] -> 3
Constraints
- 1 <= nums.length <= 3 * 10^4
- -3 * 10^4 <= nums[i] <= 3 * 10^4