#C5535. Second Largest Number in a List
Second Largest Number in a List
Second Largest Number in a List
You are given multiple test cases. For each test case, you are provided with a list of integers. Your task is to find the second largest unique integer in the list. If no such value exists (i.e. when there is only one unique integer), output -1
.
Note: The answer should be computed for each test case independently.
Hint: Remove duplicate integers from the list and then determine the second largest value.
inputFormat
Input is given via standard input. The first line contains an integer T representing the number of test cases. Each test case consists of two lines. The first line of each test case contains an integer N, the number of elements in the list. The second line contains N space-separated integers.
outputFormat
For each test case, print a single line containing the second largest unique integer. If it does not exist, print -1.## sample
4
5
2 3 6 6 5
3
1 1 1
4
7 7 8 8
2
99 100
5
-1
7
99
</p>