Maximum Depth of Binary Tree Problem
Maximum Depth of Binary Tree Problem — ExecCode Medium DSA Practice
Solve the Maximum Depth of Binary Tree problem on ExecCode. Free online medium DSA practice in Tree. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given the root of a binary tree, return 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.
Examples
Input root = [1, 2, 3, 4, 5, 6, 7, 8]; Output 4. Input root = [3, 9, 20, null, null, 15, 7]; Output 3. Input root = [1]; Output 1
Constraints
The number of nodes in the tree is in the range [0, 10^4]. -100 <= Node.val <= 100
Practice Maximum Depth of Binary Tree free on ExecCode. Browse DSA problems, topic map, and placement guides.