You are viewing a single comment's thread. Return to all comments →
for those who need it in java, here it is!
Node mergeLists(Node headA, Node headB) { if (headA == null && headB == null) return null; else if (headA == null) return headB; else if (headB == null) return headA; if(headA.data <= headB.data) headA.next = mergeLists(headA.next, headB); else { Node temp = headB; headB = headB.next; temp.next = headA; headA = temp; headA.next = mergeLists(headA.next, headB); } return headA; }
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 →
for those who need it in java, here it is!