#C4622. Find the Missing Registration Number
Find the Missing Registration Number
Find the Missing Registration Number
You are given a list of positive integers representing registration numbers. Your task is to find the smallest positive integer that is missing from the list.
For example, if the list is [1, 2, 3, 5]
, then the smallest missing registration number is 4. Formally, given a list \(\{a_1, a_2, \dots, a_n\}\), you need to determine the smallest integer \(k\) such that \(k \geq 1\) and \(k \notin \{a_1, a_2, \dots, a_n\}\).
If the list is empty, the answer is 1
.
inputFormat
The input is given via standard input (stdin) and is structured as follows:
- The first line contains a single integer \(n\) representing the number of registration numbers.
- The second line contains \(n\) space-separated integers representing the registration numbers. If \(n = 0\), the second line may be omitted.
outputFormat
Output to standard output (stdout) a single integer representing the smallest missing registration number.
## sample4
1 2 3 5
4