Back to course home
0% completed
Vote For New Content
Faster Python solution using more space O(k log n + n)
Pete Stenger
Oct 26, 2024
from heapq import * class Solution: def findKLargestNumbers(self, nums, k): # O(n) heap = [-n for n in nums] heapify(heap) # O(k log n) return [ -heappop(heap) for _ in range(k) ]
0
0
Comments
Comments