#K32732. Finding the Smallest Missing Positive Integer

    ID: 24931 Type: Default 1000ms 256MiB

Finding the Smallest Missing Positive Integer

Finding the Smallest Missing Positive Integer

Given an array of integers arr (which may include positive, negative, or zero values), your task is to find the smallest positive integer that is not present in the array.

The problem requires an efficient solution that works in O(n) time and O(1) additional space.

Hint: You may modify the input array in-place to mark the presence of integers using indices.

Input/Output: Read input from stdin and output the answer to stdout.

inputFormat

The first line contains an integer N, the number of elements in the array.
The second line contains N space-separated integers that represent the array.

outputFormat

Output a single integer: the smallest positive integer that does not appear in the array.

## sample
5
1 2 3 4 5
6