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
相关推荐
合尘猫1 小时前
图片表格变结构化数据:OCR 后的三个坑
python·ocr
小小张说故事1 小时前
Python 里弱引用到底弱在哪:拆开 weakref.ref、回调陷阱和 WeakValueDictionary
python
用户019027581611 小时前
用 DuckDB 存查 A 股 K 线:零服务、SQL 直接分析
python
Rain的Java大神之路2 小时前
LeetCode 37 解数独面试攻略:回溯 + 位掩码 + MRV,从暴力到毫秒级求解
java·后端·leetcode
程序员果子3 小时前
本体构建方法
人工智能·python·知识图谱·agent框架·本体
Pniubi3 小时前
力扣73 矩阵置零
算法·leetcode·矩阵
天天被压力3 小时前
【A股分钟级高频数据完全手册 #11】券商实时行情数据接口:实时交易(券商源)接入与字段
java·人工智能·python
总裁余(余登武)3 小时前
【python项目】:1操作EXCEl自动化开发
python·自动化·excel
芝梵家电数据笔记3 小时前
用字段表核对暖菜板长期使用条件:结构、暖区、质保边界
python·家电·数据校验·dataclass·选购
天天被压力3 小时前
【A股分钟级高频数据完全手册 #12】股票五档盘口数据接口:买卖五档实时盘口解析
java·人工智能·python