Comparator改写
MinQueue 的改写
PriorityQueueminQ = new PriorityQueue (new Comparator () { public int compare(Node n1, Node n2) { return n1.val - n2.val; }});
或者是
PriorityQueueminQ = new PriorityQueue (new Comparator (){ public int compare(Node n1, Node n2) { if(n1.val < n2.val) return -1; else if(n1.val > n2.val) return 1; else return 0; }});
MaxQueue的改写
PriorityQueuemaxQ = new PriorityQueue (new Comparator (){ public int compare(Node n1, Node n2) { return n2.val - n1.val; }});
或者是
PriorityQueuemaxQ = new PriorityQueue (new Comparator (){ public int compare(Node n1, Node n2) { if(n1.val < n2.val) return 1; else if(n1.val > n2.val) return -1; return 0; }});