We’re preparing your current view and syncing the latest data.
Given the root of a binary tree, determine 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 is the root node of a binary tree.
Return an integer representing the maximum depth of the binary tree.
The number of nodes in the tree is in the range [0, 10^4]. The tree may be empty, returning a depth of 0.
Example 1
Input
[3,9,20,null,null,15,7]
Output
3
Explanation
The longest path is 3 -> 20 -> 15 or 3 -> 20 -> 7, so maximum depth is 3.