#K81062. Smallest Missing Positive Integer
Smallest Missing Positive Integer
Smallest Missing Positive Integer
Given an array of integers, your task is to find the smallest missing positive integer. In other words, determine the minimum positive integer (i) such that (i) is not present in the array. This can be formally written as: (\min{ i \in \mathbb{Z}^{+} : i \notin A }).
For example, if the array is [1, 2, 3], the answer is 4; if the array is [1, 3, 6, 4, 1, 2], the answer is 5.
inputFormat
The input is provided via stdin and consists of two lines:
1. The first line contains an integer (n), the number of elements in the array.
2. The second line contains (n) space-separated integers representing the array elements.
outputFormat
Output a single integer on stdout: the smallest missing positive integer.## sample
3
1 2 3
4