← 返回 netflix 的题目列表Tree Depth Calculation
类型:online_judge
Given a binary tree, compute 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.
Input:
The root node of the binary tree, where node values are integers.
Output:
An integer representing the maximum depth of the binary tree.
Test Cases:
Input: root = [3,9,20,null,null,15,7], Output: 3
Input: root = [1,null,2], Output: 2
Input: root = [], Output: 0
Input: root = [0], Output: 1
Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8], Output: 5
Constraints:
The number of nodes in the tree is in the range [0, 10^4].
The tree depth will not exceed 1000.
Node values are integer values between [-10000, 10000].
Example
Input
root = [3,9,20,null,null,15,7]