Using a priority queue, I implemented my own min/max heap.