You are viewing a single comment's thread. Return to all comments →
def mergeLists(head1, head2): dummy=SinglyLinkedListNode(0) cur=dummy while head1 and head2:
if head1.data<=head2.data: cur.next=head1 head1=head1.next else: cur.next=head2 head2=head2.next cur=cur.next if head1: cur.next=head1 if head2: cur.next=head2 return dummy.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 →
def mergeLists(head1, head2): dummy=SinglyLinkedListNode(0) cur=dummy while head1 and head2: