描述
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.
分析
深度优先遍历可解,时间O(n)
,空间平均O(logn)
。
代码
Python
1 |
class (object): |
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.
深度优先遍历可解,时间O(n)
,空间平均O(logn)
。
1 |
class (object): |
近期评论