Intersection point of two linked lists

Given two linked lists, where the tail of the second list points to a node in the first list, find the node where both the lists intersect.

Consider the following example where the tail of second list points to the fourth node of the first list. The code should return 4 as the intersection point.

Capture

A simple (naive) solution is to consider each node of the first list and check if it can be reached from the second list. The first node in the first list that is reachable from the second list is the ...

 •  0 comments  •  flag
Share on Twitter
Published on May 20, 2021 07:08
No comments have been added yet.