Https://ide.codingblocks.com/s/174973

1st test gives run error ,i didn’t found any error

@Jitu748
Hello Jitendra,
errors in ur code.
a) you need to print -1 when there is no intersection which is missing in your code.
b) your while loop is like while(temp1->data!=temp2->data && temp1!=NULL && temp2!=NULL)
but actually it should be while(temp1!=NULL && temp2!=NULL && temp1->data!=temp2->data)
c) u r udating temp1=temp1->next without checking whether temp1 is NULL or not
while(i++<k)
{
temp1=temp1->next;
}
actually it should be
while(i++<k && temp1)
{
temp1=temp1->next;
}
I hope you find helpful.
regards
Aman yadav

i think these two while loops are same plzz explane the difference btw these

@Jitu748
Hello Jitendra ,
In loop or if statements condition get checked from left to right .
for example
if loop is written as follows
while(condition1 and condition2)
{
some operation
}
so here first condition1 is checked then condition2 and if any condition violates (not satisfies) loop will break.

now coming to your doubt
both loops have similar conditions but their order is different which is creating difference.
in second loop i m checking whether temp1 and temp2 are not equal to null and then checking data.

I hope this resolves your doubt

@Jitu748
Hello Jitendra let me know ,if u still have any doubt in this problem

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.