Intersection point two linked list

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

Piyush, you need to modify your approach a little bit as,
int intersection(node* head1, node* head2,int n1,int n2)
{
int len1=n1;
int len2=n2;
int diff;
if(len2>len1)
{
diff=len2-len1;
}
else
{
diff=len1-len2;
}

if(len2>len1)
{
   for(int i=0;i<diff;i++)
{
 head2=head2->next;   
}
}
else
{
for(int i=0;i<diff;i++)
{
 head1=head1->next;   
}
}


while(head1 != NULL && head2 != NULL)
 {
    if(head1->data != head2->data)
	 {
       head1 = head1->next;
    head2 = head2->next; 
    }
	else
	if(head1->data==head2->data)
	{
    return head1->data;
	}
}
return -1;

}

mam i didn’t get what is len2>len1 i&lt then u have used 4 semicolons in first for loop and the whole code is unable to understand