K-th largest element
Your task
Given a list of integers and an integer k (1 <= k <= length of the list), return the k-th largest element counted with duplicates, that is, the element in position k when the list is arranged from largest to smallest. Repeated values occupy one position each, so in [3, 8, 8, 1] the 2nd largest is 8, not 3. Write a function that returns this value.
Examples
kth_largest(nums: list[int], k: int) -> intExample 1
Input
kth_largest([3, 8, 8, 1], 2)Output
8