You are viewing a single comment's thread. Return to all comments →
@DanHaggard If you use the key argument in min/max, you can clean the code up quite a bit. Recursive example.
key
min
max
def MergeLists(headA, headB): if not headA or not headB: head = headA or headB return head head = min([headA, headB], key = lambda x:x.data) head.next = MergeLists(head.next, max([headA, headB], key = lambda x:x.data)) return 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 →
@DanHaggard If you use the
key
argument inmin
/max
, you can clean the code up quite a bit. Recursive example.