#K81372. Find the Smallest Missing Positive ID
Find the Smallest Missing Positive ID
Find the Smallest Missing Positive ID
You are given a list of N assigned positive integer IDs. Your task is to find the smallest missing positive integer that is not in the list.
More formally, let \(S\) be the set of given IDs and let \(\mathbb{Z}^+\) denote the set of all positive integers. You need to find the smallest integer \(x\) such that \(x \notin S\). For example, if \(S = \{1, 2, 3, 5, 7, 8, 10\}\), then the answer is \(4\) because \(4\) is the smallest positive integer missing from \(S\).
It is guaranteed that the input list does not necessarily contain continuous numbers, and may be empty. If the list is empty then the answer is \(1\).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(N\) representing the number of assigned IDs.
- The second line contains \(N\) space-separated integers representing the assigned IDs. If \(N = 0\), the second line may be empty.
outputFormat
Output to standard output (stdout) a single integer which is the smallest missing positive integer.
## sample7
1 2 3 5 7 8 10
4