Ranked from the Top

Imagine a ranking of results where you need to know who is in the k-th place from the top. Write find_kth_largest to return the k-th largest element in nums. Count from the largest element, starting at 1. Duplicate numbers count as separate elements, like separate places in a ranking.

Примеры

Ввод
[3, 2, 1, 5, 6, 4], 2
Вывод
5
Ввод
[3, 2, 3, 1, 2, 4, 5, 5, 6], 4
Вывод
4
Ввод
[1], 1
Вывод
1

Нужно реализовать

def find_kth_largest(nums: list[int], k: int) -> int:

Теги

arraysortingbinary-search
PostgreSQLv16

Hier verschijnt het resultaat van je code

Visible tests
1
Input
[3,2,1,5,6,4], 2
Expected5
2
Input
[3,2,3,1,2,4,5,5,6], 4
Expected4
3
Input
[1], 1
Expected1
4
Input
[7,7,7], 2
Expected7
5
Input
[-1,-2,-3,-4], 1
Expected-1
6
Input
[3,2,1,5,6,4,3,2], 1
Expected6
Focus radio
Paused · SomaFM · Fluid