摘要:
654.最大二叉树 1、使用切片 class Solution: def constructMaximumBinaryTree(self, nums: List[int]) -> Optional[TreeNode]: if len(nums) == 0: return None max_val = 阅读全文
posted @ 2023-10-30 22:43
忆象峰飞
阅读(24)
评论(0)
推荐(0)
摘要:
513.找树左下角的值 1、层序遍历迭代法 def findBottomLeftValue(self, root: Optional[TreeNode]) -> int: queue = [root] res = float('-inf') while queue: n = len(queue) f 阅读全文
posted @ 2023-10-30 21:00
忆象峰飞
阅读(11)
评论(0)
推荐(0)
摘要:
110.平衡二叉树 1、递归法 class Solution: def isBalanced(self, root: Optional[TreeNode]) -> bool: if self.get_height(root) != -1: # -1 代表高度差大于 1 return True els 阅读全文
posted @ 2023-10-30 16:35
忆象峰飞
阅读(16)
评论(0)
推荐(0)

浙公网安备 33010602011771号