Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Instead of pushing all elems to heap, we can enforce the minHeap has a size of K...

Michael Shum

Mar 1, 2023

Instead of pushing all elems to heap, we can enforce the minHeap has a size of K2. Then, pop K1 elems off the heap. Pop + Sum the rest of the elems on the Heap.

That should give us have a runtime of O(N*logK2)

0

0

Comments
Comments