Two spirit-chains in Codetikki merge at a single crossroads node and continue as one. Find that intersection point. Given two singly linked lists that intersect at some point, find the intersecting node value. The lists are non-cyclical. Input: first line m and n (lengths of the two lists before they merge, including the common tail), second line m values of list A, third line n values of list B. The lists share the same tail starting from the intersection. Output: the value of the intersecting node.
Example 1:
Example 2:
Constraints:
1 <= m, n <= 10^5 -10^9 <= node value <= 10^9 The two lists always intersect
Tags:
