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
    }
}

package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/
 */
public class Problem1502 {
    public boolean canMakeArithmeticProgression(int[] arr) {
        Arrays.sort(arr);
        int diff = arr[1] - arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] - arr[i - 1] != diff) {
                return false;
            }
        }
        return true;
    }
}

Solve problem 1502