Airbnb interview question
Do two singly linked lists share a node when either may contain a cycle?
- Company:
- Airbnb
- Round:
- Onsite
- Type:
- Coding
- Difficulty:
- Hard
- Reported:
- Q2 2026
Problem
You are given the heads of two singly linked lists, a and b. Either list may be empty, and either list may contain a cycle (its last nodes loop back to an earlier node). Lists may share nodes: once two lists reach a common node, they continue through the same nodes from there on.
Part 1. Return True if the two lists share at least one node (compared by identity, not by value), otherwise False.
Part 2 (follow-up). Return the node where the two lists first meet, or None if they share nothing. When the lists join before or at the start of a cycle, or have no cycle at all, that node is unique. When they run into one shared cycle at two different entry nodes, there is no single first shared node, so either entry node is accepted.
Ask about cycles before you start, because the cases differ.
Example 1
Input: a = 1 -> 2 -> 3 -> 4 -> 5, b = 9 -> 8 -> (node 4 of a)
Output: Part 1: True, Part 2: node 4
Both lists end with the nodes 4 -> 5, and node 4 is where they meet.
Example 2
Input: a = 1 -> 2 -> 3 -> 4 -> (back to node 2), b = 7 -> 8 -> (node 4 of a)
Output: Part 1: True, Part 2: node 2 or node 4
Both lists end in the cycle 2 -> 3 -> 4. a enters it at node 2 and b at node 4, so either entry node is accepted for Part 2.
Example 3
Input: a = 1 -> 2 -> 3 -> (back to node 1), b = 5 -> 6 -> 7
Output: Part 1: False, Part 2: None
An acyclic list can never reach a cycle, so it cannot share a node with a cyclic list.
Constraints
- Node values are arbitrary and may repeat; compare nodes by identity.
- Either list may be empty, and either may contain a cycle.
Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern