#C13131. K-th Largest Element Finder
K-th Largest Element Finder
K-th Largest Element Finder
You are given a list of integers and an integer (k). Your task is to find the (k^{th}) largest element in the list. In other words, if the list were sorted in non-increasing order, you need to output the element at the (k^{th}) position (1-indexed). The required time complexity is (O(n \log n)).
inputFormat
The input is given on two lines. The first line contains space-separated integers representing the array. The second line contains a single integer (k).
outputFormat
Output a single integer — the (k^{th}) largest element of the array.## sample
3 2 1 5 6 4
2
5