#C1149. Find the Smallest Missing Non-negative Integer
Find the Smallest Missing Non-negative Integer
Find the Smallest Missing Non-negative Integer
Given an array of non-negative integers, your task is to find the smallest non-negative integer that is missing from the array. In other words, let \(A\) be the given array, and you need to determine the smallest \(x \ge 0\) such that \(x \notin A\).
For example:
- If \(A = [0, 1, 2, 6, 9]\), then the answer is \(3\).
- If \(A = [1, 2, 3, 4]\), then the answer is \(0\).
This problem tests your ability to handle arrays and efficiently search for missing elements.
inputFormat
The input is given from standard input (stdin) in the following format:
- The first line contains a single integer \(n\) \((0 \le n \le 10^5)\), the number of elements in the array.
- The second line contains \(n\) space-separated non-negative integers.
If \(n = 0\) then the second line will be empty.
outputFormat
Output a single integer to standard output (stdout), which is the smallest non-negative integer that is not present in the given array.
## sample6
0 1 2 6 9
3