美文网首页Leetcode
104. Maximum Depth of Binary Tre

104. Maximum Depth of Binary Tre

作者: oo上海 | 来源:发表于2016-08-02 08:18 被阅读9次

    104. Maximum Depth of Binary Tree

    题目:
    https://leetcode.com/problems/maximum-depth-of-binary-tree/

    难度:

    Easy

    简单题

    
    class Solution(object):
        def maxDepth(self, root):
            """
            :type root: TreeNode
            :rtype: int
            """
            if root == None: return 0
            elif root.right == None and root.left == None: return 1
            else:
                return max(1 + self.maxDepth(root.left), 1+ self.maxDepth(root.right))
    

    相关文章

      网友评论

        本文标题:104. Maximum Depth of Binary Tre

        本文链接:https://www.haomeiwen.com/subject/eajfsttx.html