Then, using it is a matter of running the linked lists through it:
xxxxxxxxxx16
let pq = new PriorityQueue();for (let list of arrOfLists) { if (list) { let currentNode = list; pq.insert(currentNode.val); // process the rest of the list while (currentNode.next) { pq.insert(currentNode.next.val); currentNode = currentNode.next; } }}// returning this will return the head of the priority queue linked list resultreturn pq.first || [];OUTPUT
Results will appear here.