- Traverse the first linked list and store the addresses of all m nodes in a hash. O(m) time
- Now traverse the second linked list and if you see an address that already exists in hash , then return the intersecting node. Worst case occurs if intersection is at last node, hence O(n)
Total time complexity = O(m)+O(n) =O(m+n)