You are viewing a single comment's thread. Return to all comments →
python solution
def finish_llist(current, head): while head: current.next = head head = head.next current = current.next def mergeLists(head1, head2): dummyNode = SinglyLinkedListNode(None) current = dummyNode while head1 and head2: if head1.data <= head2.data: current.next = head1 head1 = head1.next else: current.next = head2 head2 = head2.next print(current.data) current = current.next finish_llist(current, head1) finish_llist(current, head2) return dummyNode.next
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 →
python solution