#LC 104•Trees•Easy
Maximum Depth of Binary Tree
Return the maximum number of nodes along a path from the root to a leaf.
Understand the problem
Return the maximum number of nodes along a path from the root to a leaf.
Example 1
Input: {"root": [3, 9, 20, null, null, 15, 7]}
Output: 3
Follow the trace to see how the algorithm reaches this result.
Constraints
- Use the input format shown in the example.
Think first
What information should you keep so you can solve the next step efficiently?
Pattern tags:Tree DFSRecursion