Maximum Depth of Binary Tree
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.
(二叉树的深度)
Example:
1. 递归
找到左子树和右子树的最大深度,从而返回该深度+1即为结果。具体实现过程如下:
1 | # Definition for a binary tree node. |