You are viewing a single comment's thread. Return to all comments →
if (headA == null || headB == null) { return (headA == null) ? headB: headA; } if (headA.data < headB.data) { headA.next = MergeLists(headA.next, headB); return headA; } headB.next = MergeLists(headB.next, headA); return headB;
Do you think this is a bit simpler? I know it tests twice.
PS: How to attach code?
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 →
Do you think this is a bit simpler? I know it tests twice.
PS: How to attach code?