Maximum Depth of Binary Tree
Easy
LC #104
dfsrecursionNot attempted yet
Given the root of a binary tree, return its maximum
depth: the number of nodes on the longest path from the
root down to a leaf. An empty tree has depth 0.
Example 1
Input: root = [3, 9, 20, None, None, 15, 7]
Output: 3
Example 2
Input: root = [1, None, 2]
Output: 2
Example 3
Input: root = []
Output: 0
Constraints
- 0 ≤ number of nodes ≤ 2 · 10^4
- -10^5 ≤ Node.val ≤ 10^5