Reverse Odd Levels of Binary Tree
A medium-tier problem at 87% community acceptance, tagged with Tree, Depth-First Search, Breadth-First Search. Reported in interviews at josh technology and 1 others.
Reverse Odd Levels of Binary Tree is a medium-difficulty tree problem that hits your screen during assessments at companies like J.P. Morgan and Josh Technology. The catch is that it looks like a standard tree traversal until you realize you need to reverse node values at specific depths, not the structure itself. That's where most candidates get tripped up. With an 86% acceptance rate, it's not algorithmically brutal, but the implementation details trip people in live coding. If you blank on the level-by-level reversal logic during your OA, StealthCoder surfaces the working solution invisibly so you can move forward.
Companies that ask "Reverse Odd Levels of Binary Tree"
Reverse Odd Levels of Binary 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 for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe core trick is a depth-first or breadth-first traversal that tracks odd-numbered levels (1-indexed), collects all node values at those levels, reverses them, and reassigns them back. Most candidates attempt an in-place tree restructuring, which overcomplicates it. The real pattern is simpler: traverse to collect values at odd depths, reverse the list, then traverse again to assign them back. Alternatively, a two-pass DFS or BFS with a level counter handles it cleanly. The problem tests whether you can distinguish between reversing tree structure and reversing node values. If this problem appears in your live OA and you stall on the level-tracking logic, StealthCoder runs invisibly in the background and gives you a clean, working implementation in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Reverse Odd Levels of Binary Tree 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 for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reverse Odd Levels of Binary Tree interview FAQ
Is this really asked at J.P. Morgan and similar firms?+
Yes. It appears in their OA rotations. The 86% acceptance rate and presence at two named companies confirm it's in active circulation. It's the kind of problem that tests basic tree fluency without being a nightmare, so it fits their interview profile.
Do I need to reverse the tree structure or just the values?+
Just the values. Don't restructure pointers or child relationships. Collect all node values at odd levels (1, 3, 5, etc.), reverse that list, and write the values back. Most mistakes come from trying to swap nodes instead of values.
Should I use BFS or DFS for this?+
Either works. BFS with a queue makes level tracking more intuitive because you process one level at a time. DFS with a depth counter works too but requires careful bookkeeping. Pick whichever feels more natural under time pressure.
How does this relate to other tree topics I should know?+
It combines level-order traversal (BFS), depth tracking (DFS), and value mutation. If you're strong on Breadth-First Search and Depth-First Search, you have the foundations. The twist is recognizing that you're not restructuring the tree, just modifying values.
What's the most common mistake in the live OA?+
Trying to swap or reverse child pointers instead of node values. Also, off-by-one errors in level indexing (0-indexed vs 1-indexed). Test with a small tree like a 3-level binary tree to catch these early. The 86% acceptance rate suggests most people get it after that clarification.
Want the actual problem statement? View "Reverse Odd Levels of Binary Tree" on LeetCode →