← 返回 bytedance 的题目列表Kth Largest Element
类型:online_judge
Given an unsorted array, find the k-th largest element in the array. Note that it is the k-th largest element in sorted order, not the k-th distinct element.
Input Format:
First line is an integer n, denoting the length of the array.
Second line is an integer array, indicating the elements in the array.
Third line is an integer k, indicating the k-th largest element you need to find.
Output Format:
Output a single integer indicating the k-th largest element in the array.
Example:
Input: 5 3 2 1 5 6 2
Output: 5
Constraints:
1 <= k <= n <= 10^4
-10^4 <= element in the array <= 10^4
Example
Input
5
3 2 1 5 6
2