Reported September 2026
Googlelinked list

Detect Duplicate Trace IDs in a Linked List

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

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

Google's September 2026 OA hands you a linked list stored as parallel arrays, and the catch is in the fine print: no map, no set, O(1) extra space. The task is simple on paper. Return true if two reachable nodes share the same case-sensitive trace ID. The hinted pattern is linked-list traversal, and the constraint is what makes it a trap for anyone who reaches for a hash set on reflex. If you blank on the setup, StealthCoder is the safety net running invisibly during the live assessment. Here's the shape of the answer before you open the invite.

The problem

You are given a finite acyclic singly linked list through three parallel inputs:
traceIds[i] is the case-sensitive trace ID stored at node i.
next[i] is the index of node i's successor, or -1 when i is the tail.
head is the first node index, or -1 for an empty list.
Return true if two different reachable nodes have exactly the same trace ID. Otherwise, return false.
Do not modify traceIds or next. Your final solution must use O(1) auxiliary space; O(n^2) time is acceptable.

Function
hasDuplicateTraceId(traceIds: String[], next: int[], head: int) → boolean

Examples
Example 1
traceIds = ["ingest","index","ingest"]
next = [1,2,-1]
head = 0
return = true
Nodes 0 and 2 both store ingest.
Example 2
traceIds = ["root","api","db"]
next = [2,-1,1]
head = 0
return = false
The traversal order is root -> db -> api, and every trace ID is distinct.
Example 3
traceIds = ["Trace-1","trace-1"]
next = [1,-1]
head = 0
return = false
Trace ID comparison is case-sensitive, so the two values are different.

Constraints
0 <= traceIds.length = next.length <= 2000.
When the arrays are empty, head == -1. Otherwise, 0 <= head < traceIds.length.
Every next[i] is -1 or a valid node index.
Following next from head visits every represented node exactly once and ends at -1.
Each trace ID contains between 1 and 32 case-sensitive printable ASCII characters.
Do not use a map, set, or another auxiliary collection whose size grows with the list.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that O(n^2) time is explicitly allowed, so the intended solution is a nested walk. Start a pointer at head. For each node, start a second pointer at its successor and walk to the tail, comparing trace IDs with string equality. Any match returns true. If the outer pointer finishes, return false. With n up to 2000, that's about 2 million comparisons of strings up to 32 characters, which is fine. Pitfalls: using a HashSet breaks the space rule. Also, don't iterate the arrays by index, because list order comes from next, not array position (Example 2 proves it). Compare case-sensitively, so Trace-1 and trace-1 differ. Handle head == -1 by returning false. Use equals, not ==, in Java. If you freeze mid-assessment, StealthCoder is the hedge that surfaces this two-pointer walk while you type.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Detect Duplicate Trace IDs in a Linked List 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 by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Detect Duplicate Trace IDs in a Linked List FAQ

What's the trick in this Google OA problem?+

The space limit is the whole problem. You can't use a set, so you compare every node against every node after it. Walk the list with an outer pointer and an inner pointer starting at the outer's next. O(n^2) time, O(1) space, and the statement says that's acceptable.

Why can't I just loop through the traceIds array?+

Because the array order isn't the list order. Example 2 has next = [2,-1,1], so the traversal goes root, db, api. You must follow next from head. Looping by index happens to work for pure duplicate detection on reachable nodes only if every node is reachable, but follow the pointers anyway to stay safe.

How hard is this one really?+

Easy if you read the constraints, annoying if you don't. The logic is a double loop. People lose points by reaching for a hash set, forgetting the empty list case, or comparing strings with reference equality. Code it in ten minutes and test the three examples.

Is the comparison case-sensitive?+

Yes. Example 3 shows Trace-1 and trace-1 return false. Use plain string equality with no lowercasing or normalization. Don't trim or modify anything either, since the IDs are printable ASCII and compared exactly.

How do I prepare for this in 48 hours?+

Write the nested pointer walk once from memory in your language. Then test head = -1, a single node, duplicates at head and tail, and a list where array order differs from traversal order. Also practice stating why you avoided a set, since the follow-up is usually about space.

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

OA at Google?
Invisible during screen share
Get it