JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

Maximum Depth of Binary Tree

发布时间 2023-06-30 10:09:59作者: Artwalker

Given the root of a binary tree, return its maximum depth.

A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Solution:

class Solution(object):
    def maxDepth(self, root):
        if root is None: 
            return 0 
        else: 
            left_height = self.maxDepth(root.left) 
            right_height = self.maxDepth(root.right) 
            return max(left_height, right_height) + 1 
    本栏目推荐文章
  • CF1201C - Maximum Median
  • cleaning of llm corpus 大模型语料清洗
  • 「Geometry of Conics」读书笔记
  • 【五期李伟平】CCF-A(AAAI'21)Game of Gradients: Mitigating Irrelevant Clients in Federated Learning
  • An improved LSTM-based model for identifying high working intensity load segments of the tractor load spectrum
  • 基于正则化的图自编码器在推荐算法中的应用 Application of graph auto-encoders based on regularization in recommendation algorithms
  • c++编译OpenSceneGraph-3.4 出现 error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
  • Redis - (error) WRONGTYPE Operation against a key holding the wrong kind of value
  • [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
  • 《大学计算机》课程简介 School of Computer Science and Engineering
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们