package leetcode;

/**
 * https://leetcode.com/problems/minimum-operations-to-make-array-equal/
 */
public class Problem1551 {
    public int minOperations(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1551 prob = new Problem1551();
        System.out.println(prob.minOperations(3)); // 2
        System.out.println(prob.minOperations(6)); // 9
    }
}

@@ -170,243 +170,384 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int m = n / 2;%0A        int%5B%5D array = new int%5Bn%5D;%0A        array%5B0%5D = 1
 ;%0A    
+ 
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1551 prob = new Problem1551();%0A        System.out.println(prob.minOperations(3)); // 2%0A        System.out.println(prob.minOperations(6)); // 9
+   for (int i = 1; i %3C= m; i++) %7B%0A            array%5Bi%5D = array%5Bi - 1%5D + 2;%0A        %7D%0A        int mid = array%5Bm%5D;%0A        if (n %25 2 == 0) %7B%0A            mid--;%0A        %7D%0A        for (int i = 0; i %3C m; i++) %7B%0A            answer += mid - array%5Bi%5D;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1551