判断一列数经过排序是否可以构成等差数列,水题
1 #1502
2 #Runtime: 23 ms (Beats 81.90%)
3 #Memory: 13.5 MB (Beats 61.90%)
4
5 class Solution(object):
6 def canMakeArithmeticProgression(self, arr):
7 """
8 :type arr: List[int]
9 :rtype: bool
10 """
11 arr.sort()
12 inc = arr[1] - arr[0]
13 for i in range(2, len(arr)):
14 if arr[i] - arr[i - 1] != arr[1] - arr[0]:
15 return False
16 return True