what am I doing wrong?
I know I am supposed to take a limited input from user but for now, I am trying to take input until"-1" is hit
Intersection point two linked lists,
Divyam when you send you code, it’s better if you comment out your steps or write down your approach, it saves time.
Alright, so just check out for the length of both the strings, and subtract the size of the smaller string from the longer string. Now you’ll start iterating from that result for the longer string, Suppose, the longer string has size 5, the smaller string has size 3. So, 5-3=2, start iterating for the longer string from 2 and for the smaller string from 0 itself. Whenever the next address (node->next) for both of them becomes equal, you get the intersection point.
Hi @MadHawk
Your loops in the check( ) run infinitely as there is no condition on either i or j to stop ever since neither the a pointer or b pointer ever get updated and their next will never reach NULL. Please follow the approach suggested above by Ajinka and let me know if your doubt persists.