#C3258. Second Largest Distinct Number
Second Largest Distinct Number
Second Largest Distinct Number
Given a list of integers, find the second largest distinct number. In other words, if you remove duplicates and sort the remaining numbers in descending order, you are to output the second element from this sorted order. Formally, let ( S = {a_1, a_2, \ldots, a_k} ) be the set of distinct integers such that ( a_1 > a_2 > \cdots > a_k ); if ( k \ge 2 ), output ( a_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.
outputFormat
Output the second largest distinct integer. If there are fewer than two distinct integers, output ( None ).## sample
6
4 2 5 1 5 3
4