#K83237. Smallest Missing Positive Integer
Smallest Missing Positive Integer
Smallest Missing Positive Integer
You are given an array of integers. Your task is to determine and print the smallest missing positive integer. In other words, find the smallest positive integer that is not present in the array.
The solution should read from standard input and write the answer to standard output.
The algorithm should run efficiently. A hint: the well-known "Smallest Missing Positive" problem can be solved in linear time.
In mathematical terms, if \(S\) is the set of positive integers in the array, you need to find the smallest integer \(k \geq 1\) such that \(k \notin S\).
inputFormat
The first line contains a single integer \(n\), representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer -- the smallest missing positive integer.
## sample5
1 2 0 -1 3
4