#C11919. Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
You are given an unsorted array of N unique integers. Your task is to find the smallest positive integer (i.e. an integer greater than 0) that is missing from the array.
This can be mathematically expressed as finding the smallest k such that \( k \in \mathbb{Z}^{+} \) and \( k \notin A \), where \( A \) is the set of array elements.
Example: For the array [1, 2, 3, 5, 6], the answer is 4 because it is the smallest positive integer that does not appear in the array.
Note that the input array may contain negative numbers and zeros, which should be ignored when determining the missing positive integer.
inputFormat
The first line contains an integer N denoting the number of elements in the array. The second line contains N space-separated integers representing the array elements.
outputFormat
Output a single integer which is the smallest missing positive integer.## sample
5
1 2 3 5 6
4