Reported September 2026
Robinhoodtree

Transitive Employee Referral Counts

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

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

The Robinhood OA reported in September 2026 hinges on one data structure: an adjacency map from referrer to their direct referrals, built from the input strings. It's a forest, so you count descendants per node with a tree traversal. If you've got an OA invite and this shows up, the problem is simpler than the wrapper makes it look. The trap is scale, since up to 10^5 edges can form a very deep chain. StealthCoder sits as a safety net for the live OA if you blank on the iterative version, but the idea fits in your head tonight.

The problem

Each string in referrals is referrer referredEmployee. The relationships form a forest: an employee has at most one direct referrer and no cycles occur.
For every employee mentioned in the input, count all direct and indirect referred descendants. Return employee=count strings sorted by employee id.

Function
referralCounts(referrals: String[]) → String[]

Examples
Example 1
referrals = ["A B","A C","B D"]
return = ["A=3","B=1","C=0","D=0"]
A refers B and C directly and D through B.
Example 2
referrals = ["x y"]
return = ["x=1","y=0"]
A leaf has no referred descendants.
Example 3
referrals = ["m n","p q"]
return = ["m=1","n=0","p=1","q=0"]
Independent referral trees are both reported.

Constraints
1 <= referrals.length <= 10^5.
Employee ids contain no spaces.
The directed relationships form a forest with no duplicate edges.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build a hash map from referrer to a list of referred employees. Also collect every id seen, because leaves must show up with =0. Find roots as nodes with no referrer, then compute subtree sizes with a post-order traversal. Count for a node is the sum over children of (child count + 1). The main pitfall is recursion depth. A chain of 10^5 employees will blow the stack in many languages, so use an explicit stack or process nodes in reverse BFS order from the roots. The second pitfall is sorting. Sort ids as strings, not by your traversal order, then format as id=count. Don't forget independent trees, like Example 3. If you freeze on the iterative traversal during the live OA, StealthCoder can hand you the working version while you stay in control of the submission.

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 Transitive Employee Referral Counts 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

⏵ The honest play

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

Robinhood 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.

Transitive Employee Referral Counts FAQ

What's the trick in the Robinhood referral counts problem?+

Build a parent-to-children map, then compute subtree sizes. Each node's answer is the sum of (child answer + 1) across its children. It's a classic descendant count on a forest, so one pass over the tree after building the map is enough.

How hard is this OA question really?+

Easy to medium. The logic is short, but the 10^5 edge limit means a naive recursive DFS can overflow the stack on a long chain. If you handle depth iteratively and include leaf nodes, you're most of the way there.

Do I need to handle employees who only appear as referred?+

Yes. Every employee mentioned must be in the output, including leaves like C and D in Example 1. Add both the referrer and the referred to your set of ids when parsing, and default their count to 0.

How should I sort the output?+

Sort by employee id as strings, then emit id=count. Don't rely on traversal or insertion order, since separate trees will interleave. Use plain lexicographic comparison unless the ids clearly need something else.

How do I prepare for this in 48 hours?+

Write subtree-size counting once with an explicit stack and once with recursion, and test a 10^5 long chain. Practice parsing the space-separated strings and sorting the output. That covers every moving part of this problem.

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

OA at Robinhood?
Invisible during screen share
Get it