# Leetcode Interview - Intersection of Two Linked Lists LCCI

`Note:`

- Pattern: When using
`2-pointer`

, let one pointer`moves first`

can have some surprising results. - Get the lengths of two linked lists.
- Create two pointers, let the pointer pointing to the longest list moves
`diff`

steps (Diff = | lengthA - lengthB |). - When
`pointerA === pointerB`

, we got the result!

`Question:`

Given two (singly) linked lists, determine if the two lists intersect. Return the interĀ secting node. Note that the intersection is defined based on reference, not value. That is, if the kth node of the first linked list is the exact same node (by reference) as the jth node of the second linked list, then they are intersecting.

`Example:`

1 | Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 |

`Code:`

1 | /** |