❤leetcode,python2❤二叉树的最大深度

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22795513/article/details/80663409
class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        if root == None:
            return 0
        else:
            return 1+max(self.maxDepth(root.left),self.maxDepth(root.right))

猜你喜欢

转载自blog.csdn.net/qq_22795513/article/details/80663409