Can make arithmetic progression from sequence

Time O(nlog(n)) Space O(1) Open original problem

We will sort the array and then check if the difference between each element is the same.

class Solution:
    def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
        arr.sort()
        diff = arr[1] - arr[0]
        for i in range(1, len(arr)):
            if arr[i] - arr[i-1] != diff:
                return False
        return True

Time complexity: O(nlog(n))
Space complexity: O(1)