This is the first example of the intersection of two linked lists on LeetCode webpage. The first linked list, A, is [4,1,8,4,5], the second one, B, is [5,6,1,8,4,5]. I found the intersection part of both linked lists is [1,8,4,5]. But the official explanation said "The intersected node's value is 8. From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B." Can anyone explain that why the started node of the intersection is "8" instead of "1" in this case? Thanks a lot!
The image provides important context (taken from https://leetcode.com/problems/intersection-of-two-linked-lists/):

You're looking for the point where the two lists start to intersect - this depends on the node connections, not their values. The "1" in both A and B do not imply that they intersect, as the image shows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With