Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def findKthLargest(self, nums: List[int], k: int) -> int:
- minheap = []
- for num in nums:
- heapq.heappush(minheap, num)
- if len(minheap) > k:
- heapq.heappop(minheap)
- return minheap[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement