#C12732. Second Largest Unique Number
Second Largest Unique Number
Second Largest Unique Number
You are given a list of integers. Your task is to find the second largest unique number in the list. A number is considered unique if it appears at least once; however, duplicates should be discarded when determining the order. In other words, after removing duplicates, if there are at least two distinct numbers, output the second largest one. Otherwise, output None
.
More formally, if the set of unique numbers is \(\{a_1, a_2, \dots, a_k\}\) sorted in descending order such that \(a_1 > a_2 > \cdots > a_k\), then your answer is \(a_2\) if \(k \ge 2\); otherwise, output \(\text{None}\).
inputFormat
The first line contains an integer n representing the number of elements in the list. The second line contains n space-separated integers.
If n is 0, the list is empty.
outputFormat
Output a single line. If there exists a second largest unique number in the list, print that number; otherwise, print None
.
8
10 4 10 1 4 -1 -3 3
4