Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second - Most effective solution solution in Clear category for Missing Number by vtflnk
def missing_number(items: list[int]) -> int:
""" Find missing number """
min_, max_ = min(items), max(items)
# Next - use formula of sum of arithmetic progression
return (1 + len(items)) * (min_ + max_)//2 - sum(items)
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. 23, 2022