Reported September 2026
LinkedIntwo pointers

Find the Intersection Node of Two Linked Lists

Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live LinkedIn OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this LinkedIn OA, reported September 2026, is comparing node values instead of node identity. Here the nodes live in one index table, so the index is the identity. Two heads, a next array, and you return the first index both chains reach. It's the classic linked list intersection problem in a thin disguise, and the hinted pattern is graph. If you blank when the live assessment starts, StealthCoder runs invisibly as a safety net and gives you the approach in real time. Most candidates won't need it once they see the trick below.

The problem

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 = 0
headB = 4
return = 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 = 0
headB = 2
return = -1
The two chains end separately, so there is no shared node.
Example 3
next = [1,2,-1]
headA = 0
headB = 0
return = 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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Two clean solutions. First: walk list A, store every visited index in a set, then walk list B and return the first index already in the set. O(n) time, O(n) space, and it's hard to get wrong. Second: the two-pointer swap. Advance pointer a and pointer b one step at a time. When a hits -1, restart it at headB. When b hits -1, restart it at headA. They either meet at the intersection or both become -1 together, so you return -1. Path lengths equalize after one switch. Pitfalls: comparing next[i] values instead of indices, forgetting that either head can be -1, and looping forever because you never let both pointers reach -1 on the no-intersection case. With 200000 nodes, recursion is a bad idea, so stay iterative. If the two-pointer version slips your mind live, StealthCoder is your hedge for writing the set version fast.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Find the Intersection Node of Two Linked Lists cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as intersection of two linked lists. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass LinkedIn's OA.

LinkedIn reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Intersection Node of Two Linked Lists FAQ

What's the trick in the LinkedIn intersection node question?+

Intersection means the same node index, not the same value. Either hash visited indices from list A and scan list B, or use two pointers that switch to the other head at the end. Both finish in linear time. The set approach is easier to get right under pressure.

How hard is this one really?+

Easy to medium. The idea is short, but the edge cases catch people: an empty list, both heads equal, and no intersection. Example 3 tests the same-head case directly. If you handle -1 heads carefully, it's a quick pass.

Why does the two-pointer swap work?+

Each pointer walks its own list, then the other one. Both travel lenA plus lenB steps total, so they line up at the shared node. If there's no overlap, they both reach -1 at the same moment and you return -1.

Can I just use a hash set?+

Yes. Walk A, add every index to a set, then walk B and return the first index found. It uses O(n) extra memory, which fits 200000 nodes fine. Interviewers may ask for the O(1) space version as a follow-up.

How do I prepare for this in 48 hours?+

Write both versions from scratch once, using the next array format instead of node objects. Test the three examples plus empty lists. Practice the loop termination condition for the two-pointer version, since that's where most bugs happen.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with LinkedIn.

OA at LinkedIn?
Invisible during screen share
Get it