문제

I've implemented a minHeap class so I am curious if, without modifying the code, it would be possible to use the minHeap class as a max heap?

도움이 되었습니까?

해결책

Just flip the sign of all your values before you put them into the heap, and again as you take them out of the heap.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top