indent preformatted text by 4 spaces
Node* findIntersection(Node* head1, Node* head2)
{
// Your Code Here
Node* temp,*temp1,*temp2,*head=NULL,*new_node;
temp=head1;
temp1=head2;
while(temp!=NULL && temp1!=NULL){
if(temp->data>temp1->data){
temp1=temp1->next;
}
else if(temp->data<temp1->data){
temp=temp->next;
}
else{
new_node=new Node(temp->data);
if(head==NULL){
temp2=new_node;
head=new_node;
}
else{
temp2->next=new_node;
temp2=new_node;
}
}
}
return head;
}
Intersection of two Sorted Linked Lists - GeeksforGeeks This is the question