The depth of a binary tree is the number of nodes on the longest path that starts at the root and goes down to a leaf (a node with no children). Given a binary tree, return its depth.
How the judge passes the data
Examples
Example 1:
Input: root = [8,4,10,2,null,null,12,1]
Output: 4
Explanation: The longest path is 8 -> 4 -> 2 -> 1. It has 4 nodes.
Example 2:
Input: root = [7,null,9,null,3]
Output: 3
Explanation: The path 7 -> 9 -> 3 has 3 nodes.
Example 3:
Input: root = [9]
Output: 1
Explanation: A tree with only a root has depth 1.