Flatten Binary Tree to Linked List
A medium-tier problem at 69% community acceptance, tagged with Linked List, Stack, Tree. Reported in interviews at Media.net and 10 others.
Flatten Binary Tree to Linked List shows up in assessments at Google, Apple, PayPal, Uber, and Salesforce. You're given a binary tree and need to flatten it in-place into a linked list using only right pointers. The acceptance rate sits at 69%, which sounds safe until you're live and realize the naive recursion approach leaks memory or writes values in the wrong order. StealthCoder solves it invisibly during your assessment if you blank on the traversal sequence or get tripped up on pointer rewiring.
Companies that ask "Flatten Binary Tree to Linked List"
Flatten Binary Tree to Linked List 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 an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe trap: most candidates try recursive flattening but mess up the order or lose references during pointer manipulation. The pattern is post-order DFS, not pre-order. You flatten the right subtree, then the left, then connect left's tail to the original right subtree. The trick is maintaining a running tail pointer so you know where to splice the next subtree. Some solutions use a stack to simulate the recursion, others track state across calls. If you've drilled Trees and DFS separately but never combined them for in-place linked-list conversion, this feels like a new problem. StealthCoder surfaces a working solution in seconds, undetected, when the pattern doesn't click live.
Pattern tags
You know the problem.
Make sure you actually pass it.
Flatten Binary Tree to Linked List 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. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Flatten Binary Tree to Linked List interview FAQ
Is this problem actually hard or does 69% acceptance mean it's overhyped?+
69% acceptance hides a gap. Pre-order vs. post-order DFS matters here. The recursion is easy; the pointer rewiring and tail tracking trip up candidates who haven't done binary tree flattening before. It's a medium that feels hard on first sight.
Do I need to use a stack or is pure recursion fine?+
Both work. Pure recursion with a helper that tracks the previous (tail) node is cleaner. Stack-based iteration works too but adds complexity. The key is post-order: process left, then right, then current. Pick whichever you're more confident coding under time pressure.
Do Google and Apple really ask this at the same difficulty?+
Yes. It appears frequently across the ten companies listed. At Google and Apple it's typically a second or third round question. It's not an easy warmup but not a hard grind either. Medium with a known trick.
What's the difference between this and other tree-to-list problems?+
Most tree-to-list problems create a new data structure. This one flattens in-place, reusing the tree nodes as linked-list nodes. That constraint changes the strategy. You're not building; you're restructuring pointers, which is trickier.
If I've only done linked-list and tree problems separately, will I be ready?+
Not necessarily. This combines both but adds the in-place constraint and post-order DFS requirement. It's a fusion problem. If you haven't seen it before, it can feel unfamiliar even with strong fundamentals in both topics.
Want the actual problem statement? View "Flatten Binary Tree to Linked List" on LeetCode →