Search⌘ K
AI Features

Intersection of Two Linked Lists

Understand how to use the two-pointers technique to determine if two singly linked lists intersect and locate the node where they begin to intersect. This lesson guides you through the problem statement, constraints, and implementation, helping you build skills for coding interviews involving linked list manipulation.

Statement

You are given the heads of two singly linked lists, headA and headB, to determine whether the two lists intersect. If they intersect, return the node where the intersection begins. Otherwise, return NULL.

Note: Linked lists intersect if they share a common node in memory, not just a node with the same value.

Constraints:

  • 11 ≤ node.val 105 ...