Python includes the heapq module for min-heaps, but I need a max heap. What should I use for a max-heap implementation in Python?
The easiest way is to invert the value of the keys and use heapq. For example, turn 1000.0 into -1000.0 and 5.0 into -5.0.
1.4m articles
1.4m replys
5 comments
57.0k users