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
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
[3,0,1]
Expected2
2
Input
[0,1]
Expected2
3
Input
[9,6,4,2,3,5,7,0,1]
Expected8
4
Input
[0]
Expected1
5
Input
[1]
Expected0
6
Input
[4,1,2]
Expected-1
Focus radio
Paused · SomaFM · Fluid