Smallest String Starting From Leaf
A medium-tier problem at 61% community acceptance, tagged with String, Backtracking, Tree. Reported in interviews at Google and 0 others.
You've got a binary tree and you need to construct strings from root to leaf, then return the lexicographically smallest one. Google asks this. The catch: you're building the string backwards, concatenating each node's value as you descend, then comparing at the leaves. The acceptance rate sits around 61%, which means roughly 4 in 10 candidates either miss the backwards-string trick or blow up their comparison logic. If you blank on the traversal order during your OA, StealthCoder solves it invisible to the proctor.
Companies that ask "Smallest String Starting From Leaf"
Smallest String Starting From Leaf 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 pattern is DFS with backtracking, but the string construction is the trap. You can't build the full string top-down and compare at the end cleanly, you need to construct character by character as you traverse, then at each leaf, decide if this path's string beats your current minimum. The obvious mistake: comparing strings mid-traversal before you've explored all paths, or building the string inefficiently. The real trick is recognizing that you should construct the string in reverse order (child to parent) and use backtracking to undo appends as you return up the tree. Most candidates know DFS and backtracking separately, but combining them for lexicographic comparison trips people up. When you hit this in a live assessment and the string logic tangles, StealthCoder runs silently and surfaces the correct traversal and comparison order in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Smallest String Starting From Leaf recycles across companies for a reason. It's medium-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.
Smallest String Starting From Leaf interview FAQ
Do I build the string top-down or bottom-up?+
You build it as you traverse downward, but you append in reverse: start with the current node's character, then append parent characters after. This way, when you hit a leaf, you've got the full root-to-leaf string ready to compare. Backtrack by removing characters as you return up the tree.
Why is the acceptance rate only 61%?+
Most candidates understand DFS and tree traversal, but combining backtracking with string construction and lexicographic comparison throws them. Common failures: comparing before all paths are explored, inefficient string building, or forgetting to backtrack and polluting comparisons with stale strings.
Is this really asked at Google or just a single report?+
It's confirmed in Google hiring data. At lower frequency than some other tree problems, but it does appear. If you're prepping for Google's DS interviews, this pattern's worth drilling because the String, Backtracking, and Tree topics all intersect here.
What's the difference between this and standard DFS tree traversal?+
Standard DFS collects values. This one builds a string, then compares. You need to track a running minimum string across all root-to-leaf paths and undo your string changes (backtrack) as you return. That extra state management is where candidates falter.
Which topic is the actual bottleneck?+
Backtracking. String and Tree traversal are baseline. The bottleneck is knowing when and how to undo your string mutations as you pop the call stack, so your comparisons stay fresh and you don't double-count or miss paths.
Want the actual problem statement? View "Smallest String Starting From Leaf" on LeetCode →