ListNode *mergeKLists(vector<ListNode *> &lists) {
int K = 1000;
int res[2001];
memset(res, 0, sizeof(res));
ListNode *head,*tNode;
for(int i = 0; i<lists.size(); i++){
tNode = lists[i];
while(tNode){
res[tNode->val+K]++; // 记录所有节点的数量
tNode = tNode->next;
}
}
head = new ListNode(0);
tNode = head;
for(int i = 0;i<2001;i++){
while(res[i]>0){
tNode->next = new ListNode(i-K);
tNode = tNode->next;
res[i]--;
}
}
return head->next;
}