FastPrepFind the Intersection Node of Two Linked Lists
Problems/Find the Intersection Node of Two Linked Lists

Find the Intersection Node of Two Linked Lists

Concentric AI logoConcentric AI● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Concentric AI online assessment. The report names the linked-list intersection task. We took the function signature, the examples, and the limits from an equivalent exercise that we already checked. Our version is about 95% the same as the reported question.

Two acyclic singly linked lists are stored in one node table. Node i points to node next[i]; a value of -1 means that the node has no successor. The integers headA and headB are the head-node indices, or -1 for an empty list.

Return the index of the first node that is reachable from both heads. Intersection is based on node identity, not equal values. Once the lists reach the same node, they share the remaining suffix. Return -1 if they do not intersect.

Function

findIntersectionNode(next: int[], headA: int, headB: int) → int

Examples

Example 1

next = [1,2,3,-1,2]headA = 0headB = 4return = 2

The first list follows 0 -> 1 -> 2 -> 3, while the second follows 4 -> 2 -> 3. Their first shared node is index 2.

Example 2

next = [1,-1,3,-1]headA = 0headB = 2return = -1

The two chains end separately, so there is no shared node.

Example 3

next = [1,2,-1]headA = 0headB = 0return = 0

Both lists start at the same node, so that head is the intersection.

Constraints

  • 0 <= next.length <= 200000
  • Every entry of next is -1 or a valid node index.
  • Each chain reachable from headA or headB is acyclic.
  • Each head is -1 or a valid node index.

More Concentric AI interview questions

  • Kth Greater Element Index to the RightOA · Seen Sep 2026
  • Count Students Outside Their Sorted PositionsOA · Seen Aug 2026
  • Maximum Profit Under a Bitwise OR LimitOA · Seen Aug 2026
  • Minimum Weighted Manhattan Travel CostOA · Seen Aug 2026
  • Rearrange a Linked List from Alternating EndsONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Merge Two Sorted ListsThe Walt Disney Company · OAThe Walt Disney Company interview questions
  • Palindrome Linked ListIntuit · OAIntuit interview questions
  • Merge Point of Two Linked ListsBank of America · OABank of America interview questions
  • Reverse Linked-List Nodes in Groups of KPeopleStrong · OA · PHONE SCREENPeopleStrong interview questions
  • Merge Two Sorted ListsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Middle of a Linked ListCisco · PHONE SCREENCisco interview questions
  • Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
  • Merge Two Sorted ListsIBM · PHONE SCREENIBM interview questions
  • Count Nodes in a ChainApple · PHONE SCREENApple interview questions
  • Detect a Cycle in a Linked ListSalesforce · PHONE SCREENSalesforce interview questions
All Concentric AI interview questionsSee Concentric AI hiring insights
Saved
class Solution {
    public int findIntersectionNode(int[] next, int headA, int headB) {
      // write your code here
    }
}
Checking account…