CT012

Crossroads of Two Chains

MediumAcceptance: 0.0%

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:

Input: 4 4 3 7 8 10 99 1 8 10
Output: 8

Example 2:

Input: 3 2 1 2 3 2 3
Output: 2

Constraints:

1 <= m, n <= 10^5 -10^9 <= node value <= 10^9 The two lists always intersect

Tags:

linked-list two-pointers
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki