Back to course home
0% completed
Vote For New Content
For the python solution in Kth Smallest Number, why is it that we are negating t...
Mitch
Aug 7, 2022
For the python solution in Kth Smallest Number, why is it that we are negating the values as we push them to the maxHeap?

1
0
Comments
Comments
Design Gurus3 years ago
To make it a maxHeap.
Unfortunately there is no maxHeap for 'heapq'. The default implementation is for min heap. To make it a max heap, we invert each number.
Mohammed Dh Abbasa year ago
it should be a min heap. I agree
On this page