Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Sort first solution in Clear category for Missing Number by amandel
from itertools import pairwise
def missing_number(items: list[int]) -> int:
s=sorted(items)
a=(s[-1]-s[0])/len(s)
return next(x for x,y in pairwise(s) if y-x>a) +a
print("Example:")
print(missing_number([1, 4, 2, 5]))
assert missing_number([1, 4, 2, 5]) == 3
assert missing_number([2, 6, 8]) == 4
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 8, 2022