School Problem's Submission isn't counted in score!

Submissions: 2946 Accuracy:


Third largest element (Function Problem)

Given an array of distinct elements, Your task is to find the third largest element in it. You have to complete the function thirdLargest which takes two argument . The first argument is the array a[] and the second argument is the size of the array (n). The function returns an integer denoting the third largest element in the array a[].

The function should return -1 if there are less than 3 elements in input.


The first line of input contains an integer T denoting the number of test cases. Then T test cases follow . The first line of each test case is N,N is the size of array.The second line of each test case contains N space separated values of the array a[ ].


Output for each test case will be  the third largest element of the array . 


1 ≤ T ≤ 100
1 ≤ N ≤ 100
1 ≤ A[ ] ≤ 100

Example(To be used for only expected output):

2 4 1 3 5


** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal, Harshit Sidhwa
Author: Shubham Joshi 1

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use, generate link and share the link here.