Write a c program to find merge point of two linked lists. You’re given the pointer to the head nodes of two linked lists that merge together at some node. Find the node at which this merger happens. The two head nodes will be different and neither will be NULL.

For Ex. the below lists merge at node element 2. Your program should return merge point element, so if below lists are given as a input then output should be 2.

Merge Point of Two Linked Lists

c function to find Merge Point of Two Linked Lists

   Find merge point of two linked lists
   Node is defined as
   struct Node
       int data;
       Node* next;

 int FindMergeNode(Node *headA, Node *headB)  
   Node *tempB;  
   int num = 0;
   bool f = false;
     tempB = headB;   
       if(tempB == headA)
         num = headA->data;
         f = true;
       tempB = tempB->next;  
     headA = headA->next;  
   return num;  



The above solution is less efficient. You can write an efficient solution and test your code at..


Related Contents to follow