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
相关推荐
郝学胜-神的一滴20 小时前
Python数据模型:深入解析及其对Python生态的影响
开发语言·网络·python·程序人生·性能优化
麦格芬23021 小时前
LeetCode 763 划分字母区间
算法·leetcode·职场和发展
free-elcmacom21 小时前
机器学习进阶<8>PCA主成分分析
人工智能·python·机器学习·pca
liu****21 小时前
Python 基础语法(二):程序流程控制
开发语言·python·python基础
大连好光景1 天前
Python打日志
运维·python·运维开发
syt_biancheng1 天前
博客系统全流程测试总结
python·selenium·测试用例·压力测试·postman
可信计算1 天前
【算法随想】一种基于“视觉表征图”拓扑变化的NLP序列预测新范式
人工智能·笔记·python·算法·自然语言处理
张广涛1 天前
【无标题】
python
月明长歌1 天前
【码道初阶】【LeetCode 110】平衡二叉树:如何用一个“Magic Number”将复杂度从O(N²)降为 O(N)?
linux·算法·leetcode
爱笑的眼睛111 天前
超越剪枝与量化:下一代AI模型压缩工具的技术演进与实践
java·人工智能·python·ai