public ListNode solution2(List<ListNode> lists) {
			ArrayList<ListNode> rest = new ArrayList<ListNode>();
			for (ListNode head : lists) {
				if (head != null)
					rest.add(head);
			}
			for (int i = (rest.size() - 1 - 1) / 2; i >= 0; i--) {
				minHeapify(rest, rest.size(), i);
			}

			ListNode dummy = new ListNode(0);
			ListNode cur = dummy;

			while (!rest.isEmpty()) {
				cur.next = rest.get(0);
				cur = cur.next;
				if (cur.next != null) {
					rest.set(0, cur.next);
					minHeapify(rest, rest.size(), 0);
					cur.next = null;
				} else {
					if (rest.size() == 1) {
						return dummy.next;
					} else {
						rest.set(0, rest.get(rest.size() - 1));
						rest.remove(rest.size() - 1);
						minHeapify(rest, rest.size(), 0);
					}
				}
			}
			return dummy.next;
		}