#K52622. Second Smallest Unique Number
Second Smallest Unique Number
Second Smallest Unique Number
You are given a list of integers. Your task is to find the second smallest unique number in the list. In other words, after removing duplicates and sorting the list in increasing order, you should output the second element. If the list does not contain at least two unique numbers, print None
.
Mathematically, let \( S \) be the set of unique numbers from the input. If \( |S| \geq 2 \) and \( S = \{a_1,a_2,\dots, a_k\} \) such that \( a_1<a_2<\dots<a_k \), then the answer is \( a_2 \). Otherwise, the answer is None
.
inputFormat
The input consists of a single line containing space-separated integers.
Example:
1 2 3 4 5
outputFormat
Output the second smallest unique number. If it does not exist, output None
.
Example:
For input 1 2 3 4 5
, the output should be 2
.
1 2 3 4 5
2