#C7387. Find the Second Largest Element
Find the Second Largest Element
Find the Second Largest Element
You are given several test cases. For each test case, you are provided with a list of integers. Your task is to find the second largest distinct integer in the list. In other words, if you form a set of the integers (i.e. remove duplicates) and then sort them in descending order, the answer is the second element of that sorted set.
If the list does not contain at least two distinct integers, output \(-1\).
Input Format: The input begins with an integer \(T\) (the number of test cases). Each test case starts with an integer \(N\) representing the number of elements in the list, followed by \(N\) space-separated integers.
Output Format: For each test case, print the second largest distinct integer on a new line. If there is no such number, print \(-1\).
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains a single integer \(T\) indicating the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the size of the list.
- The next line contains \(N\) space-separated integers.
outputFormat
For each test case, output one line containing the second largest distinct integer. If there is no such number, output \(-1\).
The output should be printed to standard output (stdout).
## sample1
5
2 3 6 6 5
5
</p>