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
Given a binary tree as follow:
The maximum depth is 3.
Solution
分治的精髓就是,把根节点,左子树,右子树的关系进行分析。
Last updated
Was this helpful?