#C13861. First Missing Positive
First Missing Positive
First Missing Positive
You are given an unsorted array of integers. Your task is to find the smallest positive integer (i.e. an integer (x) such that (x \ge 1)) that does not appear in the array.
Formally, given an array (\text{nums}), find the smallest positive integer (x) such that (x \notin \text{nums}). For example, if (\text{nums} = [3, 4, -1, 1]), then the answer is (2) because (1) is present and (2) is the smallest missing positive integer.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n), the number of elements in the array. The second line contains (n) space-separated integers representing the array elements.
outputFormat
Print a single integer to standard output (stdout): the smallest missing positive integer in the array.## sample
3
1 2 0
3