#K50712. Smallest Missing Nonnegative Integer
Smallest Missing Nonnegative Integer
Smallest Missing Nonnegative Integer
You are given an array of integers. Your task is to find and print the smallest nonnegative integer (i.e. \( \ge 0 \)) that is not present in the given array.
For example, if the array is [3, 4, -1, 1], the smallest missing nonnegative integer is 0; and if the array is [0, 1, 2, 3], then the smallest missing nonnegative integer is 4.
This problem will test your understanding of set operations and basic iteration. Read the input from stdin and print the result to stdout.
inputFormat
The input consists of two lines:
- The first line contains a single integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers. If \( n = 0 \), then the second line will be absent.
All input should be read from stdin.
outputFormat
Output a single integer which is the smallest nonnegative integer not present in the given array. The answer should be printed to stdout.
## sample4
3 4 -1 1
0
</p>