Maximum Circular Subarray
The array is circular: a subarray may wrap from the end to the start. Find the maximum non-empty subarray sum.
Input: the first line has N; the second line has N integers.
Output: the maximum circular subarray sum.
Constraints:
- 1 ≤ N ≤ 105
- −104 ≤ ai ≤ 104
Sample Tests
Input 1
5 5 -3 5 1 -2
Output 1
9
Input 2
3 -3 -2 -1
Output 2
-1
Discussion (opens after you solve — no spoilers before)
No comments yet.