You are viewing a single comment's thread. Return to all comments →
simple c++ code
Node* MergeLists(Node *headA, Node* headB) { if(!headA && !headB) { return NULL; } else if(headA && !headB) { return headA; } else if(!headA && headB) { return headB; } if(headA->data<=headB->data) { headA->next=MergeLists(headA->next,headB); return headA; } else { headB->next=MergeLists(headA,headB->next); return headB; } }
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 →
simple c++ code