Given a binary tree, find 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.
此题是最近本的二叉树递归题,使用有限深度比较一个节点左右子树的深度,选择较大的子树深度作为返回值。
代码如下:
Given a binary tree, find 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.
此题是最近本的二叉树递归题,使用有限深度比较一个节点左右子树的深度,选择较大的子树深度作为返回值。
代码如下: