#C3518. Second Largest Unique Number
Second Largest Unique Number
Second Largest Unique Number
Given a list of integers, your task is to find the second largest unique number in the list.
If the list contains fewer than two distinct numbers, output None
.
For example, if the list is [4, 3, 1, 4, 2]
, the largest unique number is 4 and the second largest unique number is 3.
In mathematical notation, let \( S \) be the set of unique integers. If \( S = \{s_1, s_2, \ldots, s_k\} \) sorted in increasing order, you need to output \( s_{k-1} \). If \( |S| < 2 \), then output None
.
inputFormat
The first line of input contains an integer n
, representing the number of elements in the list. The second line contains n
space-separated integers.
outputFormat
Output a single line containing the second largest unique number. If there is no such number, output None
.
5
4 3 1 4 2
3
</p>