#K1456. K-th Largest Element Finder
K-th Largest Element Finder
K-th Largest Element Finder
You are given an array of n integers and a positive integer k. Your task is to find the k-th largest element in the array.
The k-th largest element is the element that would be at index k-1 if the array were sorted in descending order. Formally, if the sorted array is \(a_1 \ge a_2 \ge \cdots \ge a_n\), then the answer is \(a_k\).
You need to process multiple test cases. For each test case, the input begins with two numbers: n and k, where n represents the number of elements in the array, and k is the rank of the largest element you are supposed to find. It is guaranteed that 1 \(\le k \le n\).
inputFormat
The first line of input contains a single integer T, the number of test cases.
For each test case:
- The first line contains two integers n and k (\(1 \le k \le n\)).
- The second line contains n space-separated integers representing the array elements.
All input should be read from standard input (stdin).
outputFormat
For each test case, output a single line containing the k-th largest element in the array.
All output should be written to standard output (stdout).
## sample3
5 2
3 2 1 5 6
6 4
7 10 4 3 20 15
3 1
1 2 3
5
7
3
</p>