Find the Kth Largest Element in an Array (LeetCode 215).
Asked in the Virtual Onsite stage. Candidate provided an O(n log k) heap solution and the interviewer moved on.
Write a function that returns the kth largest element in an integer array, where k is 1-based and duplicates count as separate values.
def findKthLargest(nums, k):
nums: list of integersk: integernums.def findKthLargest(nums, k):