---
# System prepended metadata

title: 1502\. Can Make Arithmetic Progression From Sequence

---

# 1502\. Can Make Arithmetic Progression From Sequence

```python=
class Solution:
    def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
        arr.sort()
        tmp=None
        for a,b in zip(arr,arr[1:]):
            if tmp==None:
                tmp=a-b
            else:
                if tmp!=a-b:
                    return False
        return True
    
"""
https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/discuss/720200/Clean-Python-3-O(N)
"""
class Solution:
    def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
        m = min(arr)
        gap = (max(arr) - m) / (len(arr) - 1)
        if gap == 0: 
            return True
        s = set(num - m for num in arr)
        return len(s) == len(arr) and all(diff % gap == 0 for diff in s)

    
class Solution:
    def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
        set_arr = set(arr)
        if len(set_arr) == 1:
            return True
        if len(set_arr) != len(arr):
            return False
        
        start = min(arr)
        end = max(arr)
        diff = (end - start) // (len(arr) - 1)
        current = start
        for _ in range(len(arr) - 1):
            current += diff
            if current not in set_arr:
                return False
        return True

```