Leetcode Hot 100 全排列
Leetcode Hot 100 经典回溯题:全排列。本文用回溯法梳理按位置填数的思路,并重点提醒 Python 里结果集必须使用切片拷贝。
1590 words
|
8 minutes
Cover Image of the Post
Leetcode Hot 100 子集
Leetcode Hot 100 经典回溯题:子集。本文用“选或不选”的二叉决策树讲清楚回溯思路,并提醒 Python 中结果集要使用切片拷贝。
1610 words
|
8 minutes
Cover Image of the Post
Leetcode Hot 100 电话号码的字母组合
Leetcode Hot 100 经典回溯题:电话号码的字母组合。本文用映射表加回溯梳理多叉树 DFS 思路,并说明为什么这题的 join 不一定需要额外拷贝。
1638 words
|
8 minutes
Cover Image of the Post
Leetcode Hot 100 腐烂的橘子
Leetcode Hot 100 图论 / BFS 经典题:腐烂的橘子。把所有初始腐烂橘子同时作为起点,按层做多源广度优先搜索,每一层就代表过去 1 分钟。
1969 words
|
10 minutes
Cover Image of the Post
Leetcode Hot 100 课程表
Leetcode Hot 100 图论经典题:课程表。把课程依赖关系建成有向图,用入度统计配合 BFS 实现拓扑排序,判断是否能学完全部课程。
1864 words
|
9 minutes
Cover Image of the Post
Leetcode Hot 100 路径总和 III
Leetcode Hot 100 二叉树与前缀和结合题:路径总和 III。本文用 DFS + 前缀和 + 哈希表讲清楚如何在线统计树中路径和等于 targetSum 的条数。
1938 words
|
10 minutes
Cover Image of the Post
Leetcode Hot 100 二叉树中的最大路径和
Leetcode Hot 100 二叉树板块高频难题:二叉树中的最大路径和。本文用递归拆解单链贡献与拐点更新,讲清楚为什么返回值不能分叉、答案却可以左右通吃。
1977 words
|
10 minutes
Cover Image of the Post
Leetcode Hot 100 对称二叉树
Leetcode Hot 100 二叉树板块经典题:对称二叉树。本文用递归拆解如何判断一棵二叉树是否关于中心轴镜像对称。
1312 words
|
7 minutes
Cover Image of the Post