You are viewing a single comment's thread. Return to all comments →
Heres the recursive python 2 / 3 solution I came to.
def MergeLists(headA, headB): if headA is None and headB is None: return None if headA is None: return headB if headB is None: return headA if headA.data < headB.data: smallerNode = headA smallerNode.next = MergeLists(headA.next, headB) else: smallerNode = headB smallerNode.next = MergeLists(headA, headB.next) return smallerNode
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 →
Heres the recursive python 2 / 3 solution I came to.