package leetcode;

/**
 * https://leetcode.com/problems/maximum-sum-circular-subarray/
 */
public class Problem918 {
    public int maxSubarraySumCircular(int[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem918 prob = new Problem918();
        System.out.println(prob.maxSubarraySumCircular(new int[]{1, -2, 3, -2})); // 3
        System.out.println(prob.maxSubarraySumCircular(new int[]{5, -3, 5})); // 10
        System.out.println(prob.maxSubarraySumCircular(new int[]{3, -1, 2, -1})); // 4
        System.out.println(prob.maxSubarraySumCircular(new int[]{3, -2, 2, -3})); // 3
        System.out.println(prob.maxSubarraySumCircular(new int[]{-2, -3, -1})); // -1
    }
}

@@ -171,15 +171,353 @@
     
-// TODO
+int answer = A%5B0%5D;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            int sum = A%5Bi%5D;%0A            answer = Math.max(answer, sum);%0A            int j = (i + 1) %25 A.length;%0A            while (j != i) %7B%0A                sum += A%5Bj%5D;%0A                answer = Math.max(answer, sum);%0A                j = (j + 1) %25 A.length;%0A            %7D%0A        %7D
 %0A   
@@ -528,17 +528,22 @@
  return 
-0
+answer
 ;%0A    %7D%0A

Update problem 918