2025年10月17日
摘要:
在家毛了好几天了,一个原因是下雨,一个原因是家里有大显示器。 但是家里的效率奇差。 自己做饭,一日三餐得刷碗,然后吃饭得时候刷剧,吃完饭了,还很难抽离出来。 今天好了,炒白菜得时候加了两勺我妈今年暑假在西安用白酒腌得红辣椒末。 吃完直接给人弄得头晕的很,睡了一觉,醒来就吃晚饭,吃完晚饭坐在电脑桌前也
阅读全文
posted @ 2025-10-17 20:14
axuu
阅读(7)
推荐(0)
2025年9月15日
摘要:
110. 平衡二叉树 - 力扣(LeetCode) 二叉树节点的深度:指从根节点到该节点的最长简单路径边的条数。 二叉树节点的高度:指从该节点到叶子节点的最长简单路径边的条数。 但leetcode中强调的深度和高度很明显是按照节点来计算的。 求深度适合用前序遍历,而求高度适合用后序遍历。 方法一:递
阅读全文
posted @ 2025-09-15 15:23
axuu
阅读(9)
推荐(0)
2025年9月14日
摘要:
222. 完全二叉树的节点个数 - 力扣(LeetCode) 1.迭代法,层序遍历 class Solution: def countNodes(self, root: Optional[TreeNode]) -> int: count = 0 if not root: return count q
阅读全文
posted @ 2025-09-14 17:25
axuu
阅读(8)
推荐(0)
2025年9月8日
摘要:
111. 二叉树的最小深度 - 力扣(LeetCode) 解法1:层序遍历 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # sel
阅读全文
posted @ 2025-09-08 21:29
axuu
阅读(8)
推荐(0)
2025年9月7日
摘要:
104. 二叉树的最大深度 - 力扣(LeetCode) 解法1:迭代法,使用层序遍历 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None):
阅读全文
posted @ 2025-09-07 22:07
axuu
阅读(10)
推荐(0)
2025年9月6日
摘要:
101. 对称二叉树 - 力扣(LeetCode) 一、递归解法: 解法1 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # sel
阅读全文
posted @ 2025-09-06 23:00
axuu
阅读(8)
推荐(0)
2025年9月5日
摘要:
590. N 叉树的后序遍历 - 力扣(LeetCode) 递归写法: 写法1:标准 DFS + extend 收集结果 class Solution: def postorder(self, root: 'Node') -> List[int]: if not root: return [] re
阅读全文
posted @ 2025-09-05 12:23
axuu
阅读(7)
推荐(0)
2025年9月2日
摘要:
226. 翻转二叉树 - 力扣(LeetCode) 方法1: 迭代法,广度优先遍历(层序遍历) class Solution: def invertTree(self, root: TreeNode) -> TreeNode: if not root: return None queue = col
阅读全文
posted @ 2025-09-02 19:27
axuu
阅读(6)
推荐(0)
2025年8月28日
摘要:
1. 102. 二叉树的层序遍历 - 力扣(LeetCode) 方法一:迭代+队列 class Solution: def levelOrder(self, root: Optional[TreeNode]) -> List[List[int]]: if not root: return [] qu
阅读全文
posted @ 2025-08-28 23:00
axuu
阅读(9)
推荐(0)
2025年8月20日
摘要:
方法一:空指针标记法 1. 迭代法前序遍历 ① 空指针标记法 class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right cl
阅读全文
posted @ 2025-08-20 18:01
axuu
阅读(9)
推荐(0)