public ListNode mergeKLists(ArrayList<ListNode> lists) {
		ListNode rst = null;
		if (lists.size() == 0)
			return null;
		else if (lists.size() == 1)
			return lists.get(0);
		PriorityQueue<ListNode> queue = new PriorityQueue<ListNode>(
				lists.size(), new ListNodeComparer());
		for (ListNode node : lists)
		{
			if (node != null )
			{
				queue.offer(node);
			}
		}
		if (queue.size() > 0)
		{
			ListNode p = queue.poll();
			if (p.next != null) queue.offer(p.next);
			rst =  p;
			
			while (queue.size() > 0)
			{
				ListNode q = queue.poll();
				if (q.next != null) queue.offer(q.next);
				p.next = q;
				p = q;
			}
			
			return rst;
		}
		return null;
	}