Can Make Arithmetic Progression From Sequence

给一个数组, 问他重新排序后, 是不是一个等差数列.

直接排序下就可以

class Solution {
    public boolean canMakeArithmeticProgression(int[] arr) {
        Arrays.sort(arr);
        boolean res = true;
        int diff = arr[0] - arr[1];
        for(int i = 1; i < arr.length - 1; i++) {
            if(arr[i] - arr[i + 1] != diff)
                res = false;
        }
        return res;
    }
}