Tuesday, March 1, 2022

Intersection point of two Linked Lists

 Find the intersection point of two linked lists? Or Intersection Point in Y Shapped Linked Lists 

There are no of solution for same.

  • Way 1(Simply we can use two loops) 
  • Way 2 (Mark Visited Nodes) 
  • Way 3(Using difference of node counts) 
  • Way 4(Make circle in first list) - Floyd’s Cycle Detection Algorithm
  • Way 6 (Traverse both lists and compare addresses of last nodes)
  • Way 7 (Use Hashing) 
  • Way 8( 2-pointer technique ):
  • Way 9 (Using distance from intersection point)

No comments:

Post a Comment