package leetcode;

/**
 * https://leetcode.com/problems/k-concatenation-maximum-sum/
 */
public class Problem1191 {
    public int kConcatenationMaxSum(int[] arr, int k) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1191 prob = new Problem1191();
        System.out.println(prob.kConcatenationMaxSum(new int[]{1,2}, 3)); // 9
        System.out.println(prob.kConcatenationMaxSum(new int[]{1,-2,1}, 5)); // 2
        System.out.println(prob.kConcatenationMaxSum(new int[]{-1,-2}, 7)); // 0
        System.out.println(prob.kConcatenationMaxSum(new int[]{1,2,-3}, 3)); // 3
        System.out.println(prob.kConcatenationMaxSum(new int[]{1,2,-3,4}, 3)); // 12
    }
}

@@ -177,15 +177,217 @@
     
-// TODO
+int answer = 0;%0A        int maxSoFar = 0;%0A        for (int i = 0; i %3C arr.length; i++) %7B%0A            maxSoFar = Math.max(maxSoFar, maxSoFar + arr%5Bi%5D);%0A            answer = Math.max(answer, maxSoFar);%0A        %7D
 %0A   
@@ -398,17 +398,22 @@
  return 
-0
+answer
 ;%0A    %7D%0A

Update problem 1191