#C14492. Find the Second Largest Unique Number

    ID: 44147 Type: Default 1000ms 256MiB

Find the Second Largest Unique Number

Find the Second Largest Unique Number

You are given a list of integers. Your task is to find the second largest unique number in the list. That is, among the distinct numbers in the list, the largest number is excluded and the next highest is returned.

If the list has fewer than two unique numbers, print None.

The solution should handle negative numbers and large values. You are expected to implement the logic without relying on built-in sorting methods.

Mathematically, if the set of unique integers is \( S \) and \( M = \max S \), you need to find \( \max\{ x \in S \mid x \neq M \} \). If such an \( x \) does not exist, output \( None \).

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains a single integer \( N \) representing the number of elements in the list.
  • The second line contains \( N \) space-separated integers.

outputFormat

The output is written to standard output (stdout) and should be a single line containing the second largest unique integer. If there is no such number, output None.

## sample
4
1 2 3 4
3