Kth Largest Element Problem Statement
Ninja enjoys working with numbers, and Alice challenges him to find the Kth largest value from a given list of numbers.
Input:
The first line contains an integer 'T', representing the number of test cases. For each test case: The first line contains two space-separated integers, 'N' and 'K', indicating the number of elements in the array and the Kth largest number to find, respectively.
Output:
For each test case, output an integer representing the Kth largest number on a new line.
Example:
Input:
2
5 2
4 5 1 3 2
6 4
7 10 4 3 20 15
Output:
4
10
Explanation:
In the first test case, the sorted array is [1, 2, 3, 4, 5]. The 2nd largest element is 4.
In the second test case, the sorted array is [3, 4, 7, 10, 15, 20]. The 4th largest element is 10.
Constraints:
1 <= T <= 50
1 <= K <= N <= 10^4
1 <= array[i] <= 10^5
Time Limit: 1 sec

AnswerBot
4mo
The task is to find the Kth largest element in a given list of numbers for each test case.
Read the number of test cases 'T'
For each test case, read the number of elements 'N' and the Kth largest numbe...read more
Help your peers!
Add answer anonymously...
Wipro Software Developer interview questions & answers
A Software Developer was asked 2mo agoQ. What languages have you used?
A Software Developer was asked 2mo agoQ. What are your qualities?
A Software Developer was asked 4mo agoQ. What is an operating system?
Popular interview questions of Software Developer
A Software Developer was asked 5mo agoQ1. What does employee respect mean to you?
A Software Developer was asked 6mo agoQ2. What is eager loading in programming?
A Software Developer was asked 6mo agoQ3. What are the concepts of Object-Oriented Programming (OOP)?
Top HR questions asked in Wipro Software Developer
A Software Developer was asked 1mo agoQ1. Tell me about yourself.
A Software Developer was asked 1mo agoQ2. Tell me about your work experience.
A Software Developer was asked 4mo agoQ3. What is your expected salary?
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

