# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = Noneclass Solution:
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
#递归
if root is None:
return 0
left_height = self.maxDepth(root.left)
right_height = self.maxDepth(root.right)
return max(left_height,right_height)+1
leetcode - 104 - 二叉树的最大深度
猜你喜欢
转载自blog.csdn.net/hustwayne/article/details/83544986
今日推荐
周排行