Next Available ID
When a system assigns new identifiers, it needs to quickly find the first number that is still unused. Given a list of already used positive IDs used, return the smallest free positive ID starting from 1. If the list is empty, the first free ID is 1.
Примеры
Ввод
[1, 2, 3]Вывод
4Ввод
[2, 3, 4]Вывод
1Ввод
[]Вывод
1Нужно реализовать
def first_free_id(used):
Теги
arraylistshashmapset
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[1,2,3]Expected
42
Input
[2,3,4]Expected
13
Input
[]Expected
14
Input
[1,3,4,100]Expected
25
Input
[5,5,1,2]Expected
36
Input
[0,0,0]Expected
1Focus radio
Paused · SomaFM · Fluid