package leetcode;

/**
 * https://leetcode.com/problems/rotate-function/
 */
public class Problem396 {
    public int maxRotateFunction(int[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem396 prob = new Problem396();
        System.out.println(prob.maxRotateFunction(new int[]{4, 3, 2, 6})); // 26
    }
}

@@ -152,24 +152,40 @@
     
-// TODO%0A
+if (A.length == 0) %7B%0A   
         
 retu
@@ -180,16 +180,17 @@
         
+ 
 return 0
@@ -199,180 +199,392 @@
     
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem396 prob = new Problem396();%0A        System.out.println(prob.maxRotateFunction(new int%5B%5D%7B4, 3, 2, 6%7D)); // 26
+    %7D%0A        long max = Long.MIN_VALUE;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            long tmpMax = 0;%0A            for (int j = 0, k = i; j %3C A.length; j++, k++) %7B%0A                if (k == A.length) %7B%0A                    k = 0;%0A                %7D%0A                tmpMax += A%5Bk%5D * j;%0A            %7D%0A            max = Math.max(max, tmpMax);%0A        %7D%0A        return (int) max;
 %0A   

Solve problem 396