To check if linked lists are connected


If head pointer of two linked lists are given, what will be the algorithm to check if the given linked lists are connected at some points along their lengths or have one or more common nodes, provided the algorithm to be used must have time complexity of O(n) or better.


The two linked lists merge at the intersection point. Therefore there’s only one intersection point.
For the algorithm, check out :