Advertisement
smj007

Untitled

Feb 18th, 2024 (edited)
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. class Solution:
  2.     def findKthLargest(self, nums: List[int], k: int) -> int:
  3.  
  4.         heapq.heapify(nums)
  5.  
  6.         while len(nums) > k:
  7.             heapq.heappop(nums)
  8.  
  9.         return nums[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement