public static ListNode mergeKListsPriorityQueue(List<ListNode> lists) {//AC
        if (lists.size() == 0) return null;
    	// define a comparator
    	Comparator<ListNode> BY_VAL = new Comparator<ListNode> () {
    		public int compare(ListNode s1, ListNode s2) {
    			return s1.val - s2.val;
    		}
    	};
    	// create a queue and add all the nodes
    	PriorityQueue<ListNode> pq = new PriorityQueue<ListNode>(lists.size(), BY_VAL);
    	for (int i = 0; i < lists.size(); ++i) {
    		if (lists.get(i) != null) pq.add(lists.get(i));
    	}
    	//merge
    	ListNode dummy = new ListNode(0);
    	ListNode tail = dummy;
    	while (pq.isEmpty() == false) {
    		ListNode temp = pq.poll();
    		tail.next = temp;
    		tail = tail.next;
    		if (temp.next != null) pq.add(temp.next);
    	}
    	//return head
    	return dummy.next;
    }