Sie sind auf Seite 1von 1

intersection(ptr1,ptr2)

{
head1=ptr1;
head2=ptr2;
while(ptr1->next != null)
{
while(ptr2->next!=null)
{
if(ptr1.val==ptr2.val)
{
ptr2=ptr2->next;
break;
}
}
if(ptr1.val==ptr2.val)
{
ptr2=head2;
}
else
{
if(ptr1==head)
{
head=ptr1->next;
ptr1=head;
}
else
{
ptr1=ptr1->next
}
}
}
}

Das könnte Ihnen auch gefallen