edited by
425 views

1 Answer

0 votes
0 votes
  1. Traverse the first linked list and store the addresses of all m nodes in a hash. O(m) time 
  2. 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)

Related questions

1 votes
1 votes
1 answer
3
Pradip Nichite asked Jan 22, 2016
749 views
Here, what will be the Head->Next , I am confused is it first element 50 or second element 29.
0 votes
0 votes
2 answers
4
Sandeep Singh asked Dec 27, 2015
613 views
Delete the duplicate nodeDelete the alternate duplicate nodeDelete the adjacent nodeNone of these