摘要:
输入是一个二叉树,输出是一个整数,表示该树的最大深度。 二叉树的深度为根节点到最远叶子节点(没有子节点的节点)的最长路径上的节点数。 示例: 给定二叉树 [3,9,20,null,null,15,7] 返回它的最大深度 3 。 相关知识 来源:https://leetcode.cn/problems 阅读全文
posted @ 2022-07-12 10:53
Vonos
阅读(357)
评论(0)
推荐(0)
摘要:
DFS 二叉树的遍历 class Solution(object): def maxDepth_dfs(self, root): if not root: return 0 queue = [root] height = 0 while queue: currentSize = len(queue) 阅读全文
posted @ 2022-07-12 10:20
Vonos
阅读(26)
评论(0)
推荐(0)

浙公网安备 33010602011771号