Python | Leetcode Python题解之第104题二叉树的最大深度

题目:

题解:

class Solution:
    def maxDepth(self, root: TreeNode) -> int:
        if not root: return 0
        queue, res = [root], 0
        while queue:
            tmp = []
            for node in queue:
                if node.left: tmp.append(node.left)
                if node.right: tmp.append(node.right)
            queue = tmp
            res += 1
        return res

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-25 18:29:12       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-25 18:29:12       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-25 18:29:12       82 阅读
  4. Python语言-面向对象

    2024-05-25 18:29:12       91 阅读

热门阅读

  1. mongoDB初体验

    2024-05-25 18:29:12       27 阅读
  2. 一个月速刷leetcodeHOT100 day08 两道DP题 一道子串

    2024-05-25 18:29:12       34 阅读
  3. uniapp Vue2钉钉h5开发pdf无法预览的问题

    2024-05-25 18:29:12       29 阅读
  4. leetcode725-Split Linked List in Parts

    2024-05-25 18:29:12       32 阅读
  5. 加载页面 跳转 新页面 vue

    2024-05-25 18:29:12       41 阅读
  6. 前端框架选择指南:React vs Vue vs Angular

    2024-05-25 18:29:12       33 阅读
  7. 设计模式--策略模式

    2024-05-25 18:29:12       32 阅读
  8. React hooks - useRef

    2024-05-25 18:29:12       34 阅读
  9. MybatisPlus优雅实现加密?

    2024-05-25 18:29:12       33 阅读