#K9626. First Missing Positive Integer

    ID: 39047 Type: Default 1000ms 256MiB

First Missing Positive Integer

First Missing Positive Integer

Given an array of integers, your task is to find the smallest missing positive integer. The array may contain unsorted integers, including negative values and duplicates. The intended solution should run in O(n) time and use constant extra space.

In mathematical terms, given an array (A), find the smallest integer ( m ) such that ( m \ge 1 ) and ( m \notin A ).

inputFormat

A single line of input containing space-separated integers, representing the elements of the array.

outputFormat

Output a single integer which is the smallest missing positive integer.## sample

1 2 0
3