#C12982. Smallest Repeated Number
Smallest Repeated Number
Smallest Repeated Number
Given a list of integers, your task is to find the smallest integer that appears more than once in the list. Formally, let \(f(x)\) denote the frequency of an integer \(x\) in the list. You are required to find the smallest integer \(x\) such that \(f(x) > 1\). If no integer satisfies this condition, output None
.
Example:
- For the input:
4 2 3 4 1 2
, the answer is2
since both 4 and 2 are repeated, but 2 is smaller. - For the input:
1 2 3 4 5
, since no integer is repeated, the answer isNone
.
Note: The input is provided in a single line from standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
A single line containing zero or more integers separated by spaces. An empty line indicates an empty list.
outputFormat
Print the smallest integer that appears more than once. If no such integer exists, print None
(without quotes).
4 2 3 4 1 2
2