Given the root of a binary tree, return its maximum depth, defined as the number of edges on the longest path from the root to any leaf. An empty tree has depth 0; a single-node tree has depth 1 (1 node, 0 edges measured here as node count by the implementation).
Input
root: root node of a binary tree (level-order encoded with null for missing children)
Output
The number of nodes on the longest root-to-leaf path.
Examples
Example 1
Inputroot = [1, 2, 3]
Output2
Example 2
Inputroot = [1, 2, 3, 4, 5, null, 6]
Output3
Constraints
0 <= number of nodes <= 10^4
Returns 0 for an empty tree.