Find the Third Greatest Element
Given an array 'ARR' of 'N' distinct integers, determine the third largest element in the array.
Input:
The first line contains a single integer 'T' representing the number of test cases. Each test case consists of: A single integer 'N', the number of elements in the array, on a new line. Followed by 'N' space-separated distinct integers that comprise the array 'ARR'.
Output:
For each test case, output the third largest element from the array 'ARR'.
Example:
Input:
T = 2
N = 5
ARR = [7, 4, 9, 1, 3]
N = 4
ARR = [10, 20, 30, 40]
Output:
4
20
Constraints:
1 <= T <= 50
3 <= N <= 104
-105 <= ARR[i] <= 105
Note:
You don’t need to print anything; it has been handled. Implement the provided function to solve the problem.

AnswerBot
1y
The task is to find the third largest element in an array of distinct integers.
Read the number of test cases 'T'
For each test case, read the number of elements 'N' and the array 'ARR'
Sort the array in...read more
Help your peers!
Add answer anonymously...
Top Associate Consultant Interview Questions Asked at Oracle Financial Services Software
Q. How can you swap two numbers without using a temporary variable?
Q. Write a code on triggers, HashMap (no. of alphabets in a string).
Q. Bubble sort algorithm and how to optimize it.
Interview Questions Asked to Associate Consultant at Other Companies
Top Skill-Based Questions for Oracle Financial Services Software Associate Consultant
Java Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Networking Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

