Problem:
Find intersection Point in Y Shaped Linked Lists
Given Two linked list, check whether both list intersect each other, if yes then find the starting node of the intersection.
Algorithm:
- Find length of both lists
- Find larger list (suppose L1) and smaller list (L2), between these lists
- Get extra_node = L1 – L2
- Now start moving a head in large list by extra_node steps.
- After moving extra_node steps in larger list, now start moving both lists
- Continue moving to next node till both node are not same.
Latest Source Code:
Github: YListFinder.java
Output:
1 2 3 4 5 6 7 8 9 101 102 4 5 6 7 8 9 Y node : Node(4)