Grokking the Coding Interview: Patterns for Coding Questions
0% completed
Kth Largest Number in a Stream (medium)
.....
.....
.....
Like the course? Get enrolled and start learning!
A
Anonymous
· 3 years ago
Initializing the min-heap with all numbers will take O(N)
Show 1 reply
A
Anonymous
· 3 years ago
Time Complexity of alternative approach would be O(N log(N)). Insertion takes O(logN) time. In the alternate approach we are first inserting all the numbers into the heap which would result in O(Nlog(n)).
A
Anonymous
· 4 years ago
// if heap has more than 'k' numbers, remove one number if (this.minHeap.length > this.k) { this.minHeap.pop(); } How does this loop enough times to pop the minHeap if this is an if statement?
Show 2 replies
Reading Progress
0%