2023-08-08 11:36:45 +0000 UTC
Kth Largest Element in an Array
Categories:
Links
Code
class Solution:
def findKthLargest(self, nums, k):
heap = []
for num in nums:
heapq.heappush(heap, num)
if len(heap) > k:
heapq.heappop(heap)
return heap[0]