https://ide.codingblocks.com/s/210184 it is working only for the test case given above and on giving any other input it is not giving any output
Interection point two linked list
Piyush, pls change your point function as the logic I have used…
int intersection(nodea,nodeb)
{
int l1 = length(a);
int l2 = length(b);
int d;
if(l1>l2)
{
d=l1-l2;
}
else
{
d=l2-l1;
}
if(l1>l2)
{
for(int i=0;i<d;i++)
{
a=a->next;
}
}
else
{
for(int i=0;i<d;i++)
{
b=b->next;
}
}
// while(a->data!=b->data and a->next!=NULL){
while(a!=NULL && b!=NULL)
{
if(a->data!=b->data)
{
a = a->next;
b = b->next;
}
else
if(a->data==b->data)
{
return a->data;
}
}
return -1;
}