package leetcode;

/**
 * https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/
 */
public class Problem1502 {
    public boolean canMakeArithmeticProgression(int[] arr) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1502 prob = new Problem1502();
        System.out.println(prob.canMakeArithmeticProgression(new int[]{3,5,1})); // true
        System.out.println(prob.canMakeArithmeticProgression(new int[]{1,2,4})); // false
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -226,314 +226,230 @@
     
-// TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1502 prob = new Problem1502();%0A        System.out.println(prob.canMakeArithmeticProgression(new int%5B%5D%7B3,5,1%7D)); // true%0A        System.out.println(prob.canMakeArithmeticProgression(new int%5B%5D%7B1,2,4%7D)); // false
+Arrays.sort(arr);%0A        int diff = arr%5B1%5D - arr%5B0%5D;%0A        for (int i = 1; i %3C arr.length; i++) %7B%0A            if (arr%5Bi%5D - arr%5Bi - 1%5D != diff) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;
 %0A   

Solve problem 1502