In this tutorial, i am going to explain how to find the intersection of two linked lists.
Given the heads of two singly linked lists. We have to write a code to find the intersection point of two linked lists. If no intersection point is found then return null.
You may assume there are no cycles anywhere in the entire linked structure. We have to solve this problem in O(n) time complexity and by using O(1) space.
For example:
Linked list 1: 4 -> 6 -> 2 -> 7 -> NULL
Linked list 2: 8 -> 2-> 7 -> NULL
In this example, the intersection point of two lists is at node 2.