Loading...
Loading...
Loading...
A contest has n scores. Print the k-th largest score. Equal scores count separately, so for scores 5 5 3 the 2nd largest is 5.
Example 1
Input
5 2 3 1 4 1 5
Output
4
The scores from largest are 5, 4, 3, 1, 1.
Example 2
Input
3 3 5 5 3
Output
3
Try the problem first. Open one hint at a time.
Keep a min-heap that never holds more than k scores.
After all scores, the top of the heap is the k-th largest.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor