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


    同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
     

    public int maxDepth(TreeNode root) {
            if(root == null){
                return 0;
            }
            return 1+Math.max(maxDepth(root.left),maxDepth(root.right));
        }

    ——2020.7.2

    我的前方是万里征途,星辰大海!!
  • 相关阅读:
    前端工程师基础课程作业
    对于API接口设计的几点看法
    socket socket.io
    移动端布局
    angularJS
    bootstrop的应用
    jquery基础
    html5本地存储
    ajax
    数据库类型
  • 原文地址:https://www.cnblogs.com/taoyuxin/p/11865161.html
Copyright © 2020-2023  润新知