You are viewing a single comment's thread. Return to all comments →
Javascript converted to array then back lol
function mergeLists(head1, head2) { var arr = [] var cur = head1 while(cur != null){ arr.push(cur.data) cur = cur.next } cur = head2 while(cur != null){ arr.push(cur.data) cur = cur.next } arr.sort((a, b) => a - b) var ll = new SinglyLinkedList() for(var i = 0; i < arr.length; i++){ ll.insertNode(arr[i]) } console.log(ll) return ll.head }
Seems like cookies are disabled on this browser, please enable them to open this website
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
Javascript converted to array then back lol