CodeMentor
.
Ask AI
Problems
Learn
C++
TCS
Core CS
HR
Progress
Search
Ctrl
K
0
Lv 1
Problems
Binary Trees
Maximum Depth of Binary Tree
Easy
LeetCode
2/3
00:00
Hint
Run
Ctrl
↵
Submit
Description
Lesson
Code walk
Solution
Easy
Binary Trees
LeetCode #104
Max Depth
1 + max(depth(left), depth(right)).
Examples
Example 1
Input
3 9 20 null null 15 7
Output
3
Example 2
Input
1 null 2
Output
2
Stuck? Take a nudge
Reveal hint 1 of 3
C++17
Autosaves
Reset
Console
Run your code to see results