Collect Coins in a Tree
A hard-tier problem at 36% community acceptance, tagged with Array, Tree, Graph. Reported in interviews at Lucid and 2 others.
Collect Coins in a Tree is a hard graph problem that's shown up at Lucid, Uber, and Graviton. At 36% acceptance, it's punishing enough to stop most candidates cold during a live OA. The trap is thinking you can greedily grab coins as you traverse. You can't. The problem requires understanding how tree structure and coin placement interact with traversal constraints. Most candidates either miss the actual constraint or implement a solution that works on examples but fails on the full test suite. If this hits your live assessment and you blank on the pattern, StealthCoder solves it invisibly while the proctor watches your screen.
Companies that ask "Collect Coins in a Tree"
Collect Coins in a Tree is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe core trick here involves recognizing that you can't just DFS through the tree and collect every coin you encounter. There's a constraint you need to decode from the problem statement, and it often involves understanding which coins are actually reachable given the tree's structure and the rules for coin collection. Candidates often confuse this with simpler tree traversals or dynamic programming coin problems. The topological sort topic hint suggests the problem might involve processing nodes in a specific order to determine reachability or validity. Common mistakes: implementing a greedy approach, not handling parent-child relationships correctly, or missing that certain coins become unreachable based on earlier decisions. When you're stuck 20 minutes into the OA with a solution that passes the sample but fails hidden tests, StealthCoder provides the working approach in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Collect Coins in a Tree recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Collect Coins in a Tree interview FAQ
How hard is this really compared to other tree problems?+
It's legitimately hard. The 36% acceptance rate puts it in the top tier of difficulty. Most medium tree problems are 50-70% acceptance. The gap comes from a non-obvious constraint that makes greedy solutions fail. Candidates who've only drilled standard DFS or DP-on-trees usually get caught here.
Do I need to know topological sort to solve this?+
The topic tag suggests it's relevant, but not every solution uses it explicitly. Understanding how to process nodes in dependency order helps, especially if the coin collection has ordering constraints. If your solution doesn't naturally involve ordering, you might be missing the pattern.
Is this still asked at Uber and other listed companies?+
Yes. It's been reported at Lucid, Uber, and Graviton. That's three solid companies in the data set. The problem isn't new, so it remains a consistent technical screen question for those orgs. If you're interviewing with any of them, this is a real risk.
What's the biggest trap candidates fall into?+
Assuming a simple DFS with coin collection works. The real problem has a constraint that breaks greedy traversal. Read the problem statement extremely carefully for limits on how many coins you can grab, which coins are reachable, or how movement works. That detail is the entire problem.
Should I study this before my OA or only if I hit it live?+
If you're interviewing at Lucid, Uber, or Graviton, studying it ahead is smart given the 36% pass rate. If not, it's a lower-frequency problem at other companies. Either way, StealthCoder is your safety net if it appears and you haven't seen the trick yet.
Want the actual problem statement? View "Collect Coins in a Tree" on LeetCode →