Find the Missing Number
Imagine you have the numbers from 0 to n, but one number has gone missing. Given a list nums containing distinct numbers from that range with exactly one value missing, find the missing number. Return that missing value.
Примеры
Ввод
[3, 0, 1]Вывод
2Ввод
[0, 1]Вывод
2Ввод
[9, 6, 4, 2, 3, 5, 7, 0, 1]Вывод
8Нужно реализовать
def missing_number(nums: list[int]) -> int:
Теги
matharray
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inVisible tests
1
Input
[3,0,1]Expected
22
Input
[0,1]Expected
23
Input
[9,6,4,2,3,5,7,0,1]Expected
84
Input
[0]Expected
15
Input
[1]Expected
06
Input
[4,1,2]Expected
-1Focus radio
Paused · SomaFM · Fluid