Tuesday 14 February 2017

Merging two sorted linked list using recursion in C hacker rank solution

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

No comments:

Post a Comment