← All questions
EasyCoding
Maximum Depth of Binary Tree
Asked at
Blinkit
Infosys
Meta
Spotify
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Define the depth of an empty subtree as zero.
- 02Recursively compute left and right subtree depths.
- 03Return one plus the larger child depth.
- 04State whether the definition counts nodes or edges and handle an empty tree.
Reference answer
Then expect these follow-ups
How would you compute minimum depth?
Tests: tree edge cases
When would BFS use less memory than DFS here?
Tests: trade-offs
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question