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
PostgreSQLv16

Тук ще се появи резултатът от изпълнението на кода

Visible tests
1
Input
[1,2,3]
Expected4
2
Input
[2,3,4]
Expected1
3
Input
[]
Expected1
4
Input
[1,3,4,100]
Expected2
5
Input
[5,5,1,2]
Expected3
6
Input
[0,0,0]
Expected1
Focus radio
Paused · SomaFM · Fluid