Open harrytothemoon opened 3 years ago
var mergeKLists = function(lists) { const arr = []; for (let list of lists) { while (list) { arr.push(list.val); list = list.next; } } arr.sort((a,b) => b - a); return arr.reduce((acc, val) => acc = new ListNode(val, acc), null); };