#C14389. Second Largest Unique Number
Second Largest Unique Number
Second Largest Unique Number
You are given a list of integers. Your task is to determine the second largest unique number in the list. To accomplish this, remove duplicate values and then sort the unique values in descending order. If the number of unique values is less than 2, then output None.
Formally, let \(S\) be the set of distinct integers from the list. If \(|S| < 2\), print None. Otherwise, if \(S\) sorted in descending order is \(\{a_1, a_2, \ldots\}\), then output \(a_2\).
Note: The input is provided via standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The first line contains a single integer n, representing the number of integers.
The second line contains n space-separated integers.
outputFormat
Print a single line containing the second largest unique integer. If there is no such number, print None
.
6
3 1 4 1 2 5
4
</p>