/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: struct mycmp{ bool operator()(ListNode* a, ListNode* b){ return a->val > b->val; } }; ListNode* mergeKLists(vector& lists) { priority_queue, mycmp> pq; /// minHeap for(int i=0;inext = temp; tail = temp; } if(temp->next !=NULL){ pq.push(temp->next); } } return head; } };