Crushing Tech Interviews with the Two Heaps Pattern
If we have a problem where we're interested in knowing the smallest in element in one part of a given set of elements and the biggest element in the other part, we can use the two heaps pattern.
Lets work through this problem together:
Implement a cl...
techsloth.io4 min read
Manish askani
Hey Sloth Nice article. A small correction.
We can insert into the max heap if the top element (i.e. the greatest element) is smaller than the element we're insertingI think this is incorrect. We should insert into max heap if the inserting element is smaller than the top element of heap and not the other way round.