#K2186. Second Smallest Number
Second Smallest Number
Second Smallest Number
You are given a list of integers. Your task is to determine the second smallest distinct number in the list. If there is no such number (i.e. if the list contains fewer than two distinct numbers), you should output None
.
In other words, if the sorted unique values of the list are \(a_1, a_2, a_3, \dots\) (where \(a_1 < a_2 < a_3 < \cdots\)), output \(a_2\) if it exists, otherwise output None
.
inputFormat
The input will be given via standard input (stdin) in the following format:
- The first line contains an integer \(n\) representing the number of elements in the list.
- The second line contains \(n\) space-separated integers.
outputFormat
Output the second smallest distinct number. If no such number exists, output None
.
4
4 1 3 2
2