Priority Queue:

常用方法:

1.offer(E e) Inserts the specified element into this priority queue

  1. poll ()

Retrieves and removes the head of this queue, or returns null if this queue is empty.

About override a new comparator:

new Comparator<ListNode>() {

        public int compare\(ListNode node1, ListNode node2\) {

           return node1.val - node2.val;

}

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

results matching ""

    No results matching ""