EASYasked at 3 companies

Binary Tree Paths

A easy-tier problem at 67% community acceptance, tagged with String, Backtracking, Tree. Reported in interviews at Revolut and 2 others.

Founder's read

Binary Tree Paths is a 60% acceptance rate problem that Google, Revolut, and Capital One ask when they want to see if you can traverse trees cleanly. The task is simple on the surface: visit every node in a tree and collect all root-to-leaf paths as strings. What trips candidates is the backtracking mechanics. You have to build paths as you recurse down, then undo them as you backtrack up, without leaving garbage. Miss that pattern and your output is malformed or your recursion breaks. If this problem hits your live OA and you blank on the backtracking setup, StealthCoder solves it in seconds, invisible to the proctor.

Companies asking
3
Difficulty
EASY
Acceptance
67%

Companies that ask "Binary Tree Paths"

If this hits your live OA

Binary Tree Paths 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. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The trick is that this problem forces you to manage state across recursive calls. Most people write a helper that takes the current node and the path so far, then append the node's value to that path string before recursing. The trap is string immutability and backtracking order. You build a string, recurse left and right, and when you hit a leaf, you record the full path. On the way back up, that path is already in your result list, so you don't undo anything. The pattern: DFS with a mutable path structure (a list, not a string), append before recurse, pop after recurse, only save paths at leaf nodes. Topics like Backtracking and Depth-First Search are the backbone here. When you see a tree problem asking you to collect multiple answers from different traversal branches, StealthCoder knows this is the pattern.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Binary Tree Paths recycles across companies for a reason. It's easy-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. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Binary Tree Paths interview FAQ

Is Binary Tree Paths actually easy, or does the backtracking trick make it medium?+

It's genuinely easy if you know the backtracking pattern. 66% acceptance rate confirms most people get it. The trick is understanding that you append to your path, recurse, then pop before returning. Once that clicks, it's five lines of logic.

Do I need to return paths as strings or lists?+

The problem expects strings. You build them by concatenating node values with a '->' separator. Build the string at the leaf, not before. This avoids the overhead of building intermediate strings during recursion.

Is this still asked at Google and other top companies?+

Yes. Google, Revolut, and Capital One all report asking it. It's a tree fundamentals check. If you can't handle this, you can't handle harder tree problems they might ask next.

How does backtracking apply here compared to other problems?+

Backtracking here means you maintain a path list, append when you visit a node, and remove when you leave. It's simpler than subset or permutation backtracking because you're just recording leaf paths, not exploring all combinations.

What's the most common mistake candidates make?+

Forgetting to pop the node from the path after recursing, or trying to build the string during recursion instead of at the leaf. Both break your output. Test with a three-node tree to catch it early.

Want the actual problem statement? View "Binary Tree Paths" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.