Intersection point two linked lists

code link : https://pastebin.com/cTgwmx8Y
I am getting one ca and 2 wa what’s wrong in my code

@Divya_321 hey divya modify your code according to this
int intersection(node * head1,node * head2){
node*temp=head 1;
while(head2!=NULL){
while(head1!=NULL){
if(head1->data==head2->data){
return head1->data;
}
head1=head1->next;
}
head1=temp;
head2=head2->next;
}
return-1;
}

here why we are comparing data it should be addresses right there can be same data in two linked list

CODE LINK : https://pastebin.com/NTLkSREY
EVEN AFTER FOLLOWING YOUR APPROACH IT FAILS 1 OUT OF 3 TEST CASES , PLEASE CORRECT IT

@Divya_321 hey divya in your code I think you’re returning the zero but question demand for the -1 if intersection is not found.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.