You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it.
/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode[]} lists
* @return {ListNode}
*/
// Divide and conquer approach
// O(Nlogk) time, O(1) space
varmergeKLists=function(lists){
const numLists = lists.length;
let interval =1;
// Continuously merge two lists at a time (each time we'll merge one new list with the existing merged list)
while(interval < numLists){
for(let i =0; i < numLists - interval; i += interval *2){