#K33957. First Missing Positive Integer
First Missing Positive Integer
First Missing Positive Integer
Given an unsorted array of integers, find the smallest missing positive integer. In other words, identify the minimum positive integer that does not appear in the array.
Note: It is expected to design an algorithm with an expected time complexity of O(n) and constant extra space.
For example, given the array [1, 2, 0, 7, 5]
, the smallest missing positive integer is 3.
inputFormat
The first line contains an 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 from the array.## sample
5
1 2 0 7 5
3
</p>