#K60477. Find Missing Code

    ID: 31095 Type: Default 1000ms 256MiB

Find Missing Code

Find Missing Code

You are given a list of integer codes which may include duplicates and negative numbers. Your task is to find the smallest missing positive integer (code) from the list.

For example, for the list [3, 4, 7, 1], the smallest missing positive code is 2. Similarly, for [1, 2, 3, 5] the answer is 4. If the list is empty or does not contain any positive integers, the answer is 1.

The problem is to determine the first positive integer that does not appear in the given list.

Note: The input is provided in a single line from standard input (stdin) as space‐separated integers. The output should be printed to standard output (stdout).

inputFormat

The input consists of a single line containing space-separated integers representing the list of codes. If the line is empty or contains only whitespace, it should be considered as an empty list.

outputFormat

Output a single integer — the smallest missing positive integer.

For example:

Input: 3 4 7 1
Output: 2
## sample
3 4 7 1
2