ByteByteGo logo
menuProblems List

Linked List Intersection

Easy

Return the node where two singly linked lists intersect. If the linked lists don't intersect, return null.

Example:

Output: Node 8

How the custom test cases work:

The input is designed to describe how the two input linked lists intersect. Here's how the skip inputs work:

  • skip_A: The number of nodes to skip in list A (from the head) to reach the intersection node.
  • skip_B: The number of nodes to skip in list B (from the head) to reach the intersection node.

For a linked list with no intersection, set skip_A and skip_B to the length of their respective linked lists, which effectively skips all nodes in each linked list.

You can practice coding exercises online by logging into bytebytego.com on your laptop.