Kth Largest Element

Medium 40 XPSortingHeapArrays

Commonly asked at Amazon, Facebook, Microsoft

Read a list of integers and k. Print the k-th largest element (counting duplicates, so in 3 3 1 the 2nd largest is 3).

Input
Line 1: integers. Line 2: k.
Output
The k-th largest element.

Sample 1

Input

3 2 1 5 6 4
2

Output

5

Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.
The solution unlocks after 3 submissions.