1 class Solution: 2 def missingNumber(self, arr: 'List[int]') -> int: 3 n = len(arr) 4 common = (arr[n-1] - arr[0]) // n 5 if common == 0: 6 return 0 7 for i in range(n): 8 need = arr[0] + common * i 9 if arr[i] != need: 10 return need
1 class Solution: 2 def missingNumber(self, arr: 'List[int]') -> int: 3 n = len(arr) 4 common = (arr[n-1] - arr[0]) // n 5 if common == 0: 6 return 0 7 for i in range(n): 8 need = arr[0] + common * i 9 if arr[i] != need: 10 return need