~/boss / tree-height
Maximum depth of a binary tree (recursion)
The Tall Tree
How tall is the monster tree? Let the answers bubble up from the leaves.
Loading the fight…
How to beat it
An empty spot is 0 tall. Every monster asks its left child, then its right, and answers 1 + the taller answer. So the leaves answer first, and the root answers last with the height of the whole tree.
Now the real boss
Interviews ask for the code. Watch it run, then write it yourself, tested in Python, C++ or Java.
On your phone? Writing code is easier on a laptop: open bossfight.dev/problems/maximum-depth-of-binary-tree there. Sign in with your email to keep your progress on every device.