Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 554 Bytes

1502 Can Make Arithmetic Progression From Sequence 514c47a9b05845e0853456a01d79e357.md

File metadata and controls

21 lines (17 loc) · 554 Bytes

1502. Can Make Arithmetic Progression From Sequence

LeetCode - The World's Leading Online Programming Learning Platform

class Solution {
    public boolean canMakeArithmeticProgression(int[] arr) {
        Arrays.sort(arr);

         int n = arr[0] - arr[1] ;

        for (int i = 1; i < arr.length -1 ; i++)
        {
            if ((arr[i] - arr[i+1]) != n ){
                return false;
            }
        }
        return true;
    }
}