• + 0 comments

    I get inspiration from your answer:

    Node* MergeLists(Node *headA, Node* headB)
    {
      // This is a "method-only" submission. 
      // You only need to complete this method 
        if(headA == NULL&& headB != NULL)
            return headB;
        if(headB == NULL&& headA != NULL)
            return headA;
        if(headA == NULL && headB == NULL)
            return NULL;
        if(headA->data < headB->data){
           headA->next = MergeLists(headA->next,headB);
           return headA;
        }
        headB->next = MergeLists(headA,headB->next);
        return headB;
    }