1502. Can Make Arithmetic Progression From Sequence
Содержание
class Solution:
def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
a = min(arr)
b = max(arr)
n = len(arr)
if (b - a) % (n - 1):
return False
d = (b - a) // (n - 1)
s = set(arr)
return all(a + d * i in s for i in range(n))