Back to course home
0% completed
Vote For New Content
K LOG K runtime?
Ike Nwankwo
Oct 26, 2023
The solution says it can be optimized to run in KLOGK but it doesn't list the optimization. Can someone post it?
0
0
Comments
Comments
Miguel a year ago
Yes. It looks something like this:
from heapq import * class Solution: # Time: O(klogk) | Space: O(d) def findMaximumDistinctElements(self, nums, k): distinctElementsCount = 0 minHeap = [] counts = {} for num in nums: counts[nu...
On this page