New update is available. Click here to update.

Posted: 20 Nov, 2020

Difficulty: Moderate

```
Consider the array {2,1,5,6,3,8} and 'K' = 3, the sorted array will be {8, 6, 5, 3, 2, 1}, and the 3rd largest element will be 5.
```

```
1) Kth largest element in an array is the kth element of the array when sorted in non-increasing order.
2) All the elements of the array are pairwise distinct.
```

```
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains two space- separated integers 'N' and 'K', as described in the problem statement.
The second line of each test case contains 'N' space-separated integers, representing the elements of the array.
```

```
For each test case, print a single integer denoting the kth largest number in the given array.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 100
1 <= N <= 10^4
1 <= ARR[i] <= 10^9
1 <= K <= N
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Missing Number

Posted: 30 Oct, 2022

Difficulty: Easy

Longest Subarray With Zero Sum

Posted: 3 Nov, 2022

Difficulty: Moderate

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Negative To The End

Posted: 16 Dec, 2022

Difficulty: Easy

Categories:

Popular Courses: