Python | Leetcode Python题解之第559题N叉树的最大深度

题目:

题解:

python 复制代码
class Solution:
    def maxDepth(self, root: 'Node') -> int:
        if root is None:
            return 0
        ans = 0
        queue = [root]
        while queue:
            queue = [child for node in queue for child in node.children]
            ans += 1
        return ans
相关推荐
wshlp123456几秒前
deepseek api 灵活使用
python
AI视觉网奇28 分钟前
coco json 分类标注工具源代码
开发语言·python
小南家的青蛙1 小时前
LeetCode LCR 085 括号生成
算法·leetcode·职场和发展
要加油GW1 小时前
python使用vscode 需要配置全局的环境变量。
开发语言·vscode·python
B站计算机毕业设计之家1 小时前
python图像识别系统 AI多功能图像识别检测系统(11种识别功能)银行卡、植物、动物、通用票据、营业执照、身份证、车牌号、驾驶证、行驶证、车型、Logo✅
大数据·开发语言·人工智能·python·图像识别·1024程序员节·识别
晨非辰1 小时前
《数据结构风云》递归算法:二叉树遍历的精髓实现
c语言·数据结构·c++·人工智能·算法·leetcode·面试
Dream it possible!1 小时前
LeetCode 面试经典 150_链表_LRU 缓存(66_146_C++_中等)(哈希表 + 双向链表)
c++·leetcode·链表·面试
快乐的钢镚子2 小时前
思腾合力云服务器远程连接
运维·服务器·python
苏打水com2 小时前
爬虫进阶实战:突破动态反爬,高效采集CSDN博客详情页数据
爬虫·python
夫唯不争,故无尤也2 小时前
三大AI部署框架对比:本地权重与多模型协作实战
人工智能·python·深度学习