#C770. Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
You are given a list of integers and your task is to find the smallest missing positive integer.
For example, given the list [1, 2, 0], the smallest missing positive integer is 3, and for [3, 4, -1, 1] the answer is 2.
The problem can be expressed mathematically as follows:
$$\text{answer} = \min\{ k \in \mathbb{N} : k \notin \{a_1, a_2, \cdots, a_n\} \} $$You must read input from standard input (stdin) and print the output to standard output (stdout).
inputFormat
The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers.
outputFormat
Output a single integer, which is the smallest missing positive integer.## sample
3
1 2 0
3