K个排序链表归并【23】(hard)
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {
}
};
bool cmp(const ListNode *a, const ListNode *b) {
return a->val < b->val; }
class Solution {
public:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
ListNode *temp_head = new ListNode(-1);
ListNode *pre = temp_head;
while (l1 && l2) {