Java优先队列实现大顶堆和小顶堆
//默认为小顶堆
PriorityQueue<Integer> minHeap = new PriorityQueue<>(k, (a,b)->a-b);
PriorityQueue<Integer> minHeap = new PriorityQueue<>(k, new Comparator<Integer>() {
@Override
public int compare(Integer .
原创
2022-03-02 17:13:07 ·
2108 阅读 ·
0 评论