Dsa
Trees
Easy
Max Depth of Binary Tree
Given a binary tree, write a program to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. The input tree is represented as a space-separated string where 'null' signifies no node.
Example:
Input:
3 9 20 null null 15 7
Output:
3
Key concepts
treesdepthrecursion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now