import heapq class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ pq=[] for n in nums: heapq.heappush(pq,n) if(len(pq)>k): heapq.heappop(pq) return pq[0]
import heapq class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ pq=[] for n in nums: heapq.heappush(pq,n) if(len(pq)>k): heapq.heappop(pq) return pq[0]