码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode——104. 二叉树的最大深度

时间:2019-11-15 12:23:11      阅读:62      评论:0      收藏:0      [点我收藏+]

标签:内存   ret   tin   return   div   int   col   pre   style   

同111题

class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        if not root:
            return 0
        left = self.maxDepth(root.left) 
        right = self.maxDepth(root.right) 
        return max(left,right)+1 
执行用时 :32 ms, 在所有 python 提交中击败了76.27%的用户
内存消耗 :14.7 MB, 在所有 python 提交中击败了23.02%的用户
——2019.11.15

leetcode——104. 二叉树的最大深度

标签:内存   ret   tin   return   div   int   col   pre   style   

原文地址:https://www.cnblogs.com/taoyuxin/p/11865161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!