力扣 hot100题单分类
总纲
https://programmercarl.com/hot100/
hot100 链接:
https://leetcode.cn/studyplan/top-100-liked/
数组 + 双指针
代码随想录里 双指针是 第五章,不过也是对 数组、链表里的题目,是对前面题目的总结。hot100这里就把双指针放在前面。
目标:掌握最核心的两种套路
核心套路
双指针
滑动窗口
题目
283.移动零:https://leetcode.cn/problems/move-zeroes/solutions/490356/283-yi-dong-ling-shuang-zhi-zhen-xiang-jie-by-ca-2/?envType=study-plan-v2&envId=top-100-liked
11.盛最多水的容器:https://leetcode.cn/problems/container-with-most-water/solutions/3909487/shuang-zhi-zhen-zhe-yao-yong-cjavagopyth-45gg/?envType=study-plan-v2&envId=top-100-liked
15.三数之和:https://leetcode.cn/problems/3sum/solutions/1968332/shuang-zhi-zhen-xiang-bu-ming-bai-yi-ge-pno55/?envType=study-plan-v2&envId=top-100-liked
42.接雨水: https://leetcode.cn/problems/trapping-rain-water/solutions/616404/42-jie-yu-shui-shuang-zhi-zhen-dong-tai-wguic/?envType=study-plan-v2&envId=top-100-liked
https://leetcode.cn/problems/trapping-rain-water/solutions/1974340/zuo-liao-nbian-huan-bu-hui-yi-ge-shi-pin-ukwm/?envType=study-plan-v2&envId=top-100-liked
下面这几个子串的滑动窗口思路都是相同的:
*3.无重复字符的最长子串 :https://leetcode.cn/problems/longest-substring-without-repeating-characters/solutions/4026327/3-shi-yong-shuang-zhi-zhen-jie-by-funny-2gbmm/
*438.找到字符串中所有字母异位词:https://leetcode.cn/problems/find-all-anagrams-in-a-string/solutions/2969498/liang-chong-fang-fa-ding-chang-hua-chuan-14pd/?envType=study-plan-v2&envId=top-100-liked
https://leetcode.cn/problems/find-all-anagrams-in-a-string/solutions/4026894/437-ding-chang-hua-chuang-by-funny-yalow-wve0/ 定长滑窗
76.最小覆盖子串 滑动窗口:https://leetcode.cn/problems/minimum-window-substring/solutions/3951260/hua-dong-chuang-kou-zhe-yao-wan-76-zui-x-btu3/
https://leetcode.cn/problems/minimum-window-substring/solutions/4026218/76-hua-dong-chuang-kou-by-funny-yalowhvh-9ms1/
能力要求:能写出双指针 + 窗口模板
二分查找
目标:掌握边界
核心套路
左闭右闭
左闭右开
题目
33.搜索旋转排序数组
34.在排序数组中查找元素的第一个和最后一个位置
74.搜索二维矩阵
能力要求:写对边界
链表
目标:掌握指针操作
核心套路
虚拟头结点
快慢指针
题目
推荐顺序:206 → 21 → 2 → 19 → 160 → 141 → 142 → 234 → 24 → 25 → 138 → 148 → 23 → 146
206.反转链表:https://leetcode.cn/problems/reverse-linked-list/solutions/1718107/by-carlsun-2-uh1f/?envType=study-plan-v2&envId=top-100-liked
21.合并两个有序链表:https://leetcode.cn/problems/merge-two-sorted-lists/solutions/2373691/liang-chong-fang-fa-die-dai-di-gui-pytho-wf75/?envType=study-plan-v2&envId=top-100-liked
2.两数相加:https://leetcode.cn/problems/add-two-numbers/solutions/2327008/dong-hua-jian-ji-xie-fa-cong-di-gui-dao-oe0di/?envType=study-plan-v2&envId=top-100-liked
19.删除链表的倒数第 N 个结点:https://leetcode.cn/problems/remove-nth-node-from-end-of-list/solutions/877376/dai-ma-sui-xiang-lu-dai-ni-gao-ding-lian-0ohj/?envType=study-plan-v2&envId=top-100-liked 快慢指针
*160.相交链表:https://leetcode.cn/problems/intersection-of-two-linked-lists/solutions/811955/dai-ma-sui-xiang-lu-160-xiang-jiao-lian-wxkmq/?envType=study-plan-v2&envId=top-100-liked
141.环形链表:https://leetcode.cn/problems/linked-list-cycle/solutions/628959/141-huan-xing-lian-biao-shuang-zhi-zhen-4uc9q/?envType=study-plan-v2&envId=top-100-liked
*142.环形链表 II:https://leetcode.cn/problems/linked-list-cycle-ii/solutions/441306/142-huan-xing-lian-biao-ii-jian-hua-gong-shi-jia-2/?envType=study-plan-v2&envId=top-100-liked
*234.回文链表:https://leetcode.cn/problems/palindrome-linked-list/solutions/625055/234-hui-wen-lian-biao-shu-zu-mo-ni-fan-z-70k9/?envType=study-plan-v2&envId=top-100-liked 1 链表值遍历+双指针;3 快慢指针+翻转链表;
*24.两两交换链表中的节点:https://leetcode.cn/problems/swap-nodes-in-pairs/solutions/1720490/by-carlsun-2-mav4/?envType=study-plan-v2&envId=top-100-liked
https://leetcode.cn/problems/swap-nodes-in-pairs/solutions/4027462/24-zhe-yang-xie-ke-neng-geng-qing-chu-yi-hl6f/
以下的暂时感觉没有必要写。
25.k个一组翻转链表:https://leetcode.cn/problems/reverse-nodes-in-k-group/solutions/1992228/you-xie-cuo-liao-yi-ge-shi-pin-jiang-tou-plfs/?envType=study-plan-v2&envId=top-100-liked
138.随机链表复制:https://leetcode.cn/problems/copy-list-with-random-pointer/solutions/2993775/bu-yong-ha-xi-biao-de-zuo-fa-pythonjavac-nzdo/?envType=study-plan-v2&envId=top-100-liked
148.链表排序:https://leetcode.cn/problems/sort-list/solutions/2993518/liang-chong-fang-fa-fen-zhi-die-dai-mo-k-caei/?envType=study-plan-v2&envId=top-100-liked
23.合并k个升序链表:https://leetcode.cn/problems/merge-k-sorted-lists/solutions/2384305/liang-chong-fang-fa-zui-xiao-dui-fen-zhi-zbzx/?envType=study-plan-v2&envId=top-100-liked
146.lru缓存:https://leetcode.cn/problems/lru-cache/solutions/2456294/tu-jie-yi-zhang-tu-miao-dong-lrupythonja-czgt/?envType=study-plan-v2&envId=top-100-liked
能力要求:熟练画图 + 指针推导
哈希表
目标:空间换时间
核心套路
哈希去重
计数
题目
1.两数之和
49.字母异位词分组
128.最长连续序列
能力要求:一眼识别“哈希解法”
字符串
目标:字符串处理能力
核心套路
双指针/滑动窗口
KMP(理解即可)
题目
- 和为 K 的子数组:https://leetcode.cn/problems/subarray-sum-equals-k/solutions/2781031/qian-zhui-he-ha-xi-biao-cong-liang-ci-bi-4mwr/ 前缀和+维护一个哈希表
能力要求:窗口 + 子串问题建模
栈
目标:掌握“单调结构”
核心套路
单调栈
题目
20.有效的括号
155.最小栈
739.每日温度
84.柱状图中最大的矩形
能力要求:识别“下一个更大元素”问题
二叉树
目标:建立递归思维
核心套路
前中后序递归 层序遍历(BFS)
题目
104 → 226 → 101 → 94 → 102 → 543 → 199 → 98 → 230 → 108 → 105 → 114 → 437 → 236 → 124
广度优先搜索:
104.二叉树的最大深度:https://leetcode.cn/problems/maximum-depth-of-binary-tree/solutions/1797307/by-carlsun-2-ojzh/
102.层序遍历:https://leetcode.cn/problems/binary-tree-level-order-traversal/solutions/673131/er-cha-shu-ceng-xu-bian-li-deng-chang-wo-90ot/
199.二叉树右视图:https://leetcode.cn/problems/binary-tree-right-side-view/solutions/859784/dai-ma-sui-xiang-lu-wo-yao-da-shi-ge-er-mdkms/
深度优先搜索:
94.二叉树的中序遍历:https://leetcode.cn/problems/binary-tree-inorder-traversal/solutions/859693/dai-ma-sui-xiang-lu-che-di-chi-tou-qian-xjof1/
https://leetcode.cn/problems/binary-tree-inorder-traversal/solutions/4024784/zhong-xu-bian-li-die-dai-fa-by-funny-yal-0gmx/
226.翻转二叉树:https://leetcode.cn/problems/invert-binary-tree/solutions/847310/dai-ma-sui-xiang-lu-226-fan-zhuan-er-cha-8tvd/ 迭代法求解和前序遍历的求解一致。
*101.对称二叉树:https://leetcode.cn/problems/symmetric-tree/solutions/862694/dai-ma-sui-xiang-lu-dai-ni-xue-tou-er-ch-hnjo/
543.二叉树的直径:https://leetcode.cn/problems/diameter-of-binary-tree/solutions/4018859/liang-chong-fang-fa-jie-543-by-funny-yal-dqh7/
105.构造二叉树:https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/solutions/867923/dai-ma-sui-xiang-lu-dai-ni-xue-tou-er-ch-g155/
230. 二叉搜索树中第k个小的元素:中序遍历,得到数组,返回第k个。
98.验证二叉搜索树:https://leetcode.cn/problems/validate-binary-search-tree/solutions/867999/dai-ma-sui-xiang-lu-dai-ni-xue-tou-er-ch-9cc0/
*108.有序数组转化为二叉搜索树:https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/solutions/3945332/shi-pin-jiang-jie-xue-tou-er-cha-shu-xia-lv4m/ 二分
114.二叉树展开为链表:https://leetcode.cn/problems/flatten-binary-tree-to-linked-list/solutions/4019812/114-xian-xu-bian-li-jie-by-funny-yalowhv-lspe/
*437.二叉树路径总和:https://leetcode.cn/problems/path-sum-iii/solutions/2784856/zuo-fa-he-560-ti-shi-yi-yang-de-pythonja-fmzo/
https://leetcode.cn/problems/path-sum-iii/solutions/4025595/437-jie-fa-dfshui-su-ha-xi-biao-by-funny-pga6/ 搭配560看更清晰
*236.最大公共祖先:https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/solutions/625063/236-er-cha-shu-de-zui-jin-gong-gong-zu-x-tl5b/
*124.二叉树中最大路径和:https://leetcode.cn/problems/binary-tree-maximum-path-sum/solutions/2227021/shi-pin-che-di-zhang-wo-zhi-jing-dpcong-n9s91/
https://leetcode.cn/problems/binary-tree-maximum-path-sum/solutions/4025709/124-cppqiu-jie-by-funny-yalowhvh-a1t5/
能力要求:写递归不慌
回溯
目标:理解“树形搜索”
核心套路
回溯模板
题目
77.组合
78.子集
46.全排列
39.组合总和
22.括号生成
能力要求:画树 + 剪枝
贪心
题目
56.合并区间
动态规划
目标:掌握状态转移
核心套路
dp数组含义
状态转移方程
题目
单个动态规划:
70.爬楼梯:https://leetcode.cn/problems/climbing-stairs/solutions/545230/70-pa-lou-ti-dong-tai-gui-hua-jing-dian-a3na7/ 1普通dp2完全背包
118.杨辉三角:https://leetcode.cn/problems/pascals-triangle/solutions/2784222/jian-dan-ti-jian-dan-zuo-pythonjavaccgoj-z596/
198.打家劫舍:https://leetcode.cn/problems/house-robber/solutions/994214/dai-ma-sui-xiang-lu-dai-ni-xue-tou-dong-ezvt3/
416.分割等和子集:https://leetcode.cn/problems/partition-equal-subset-sum/solutions/553978/bang-ni-ba-0-1bei-bao-xue-ge-tong-tou-by-px33/
322.零钱兑换:https://leetcode.cn/problems/coin-change/solutions/975451/dai-ma-sui-xiang-lu-dai-ni-xue-tou-wan-q-80r7/ 组合数和排列数,个人理解是组合数没有顺序;排列数是有顺序的,所以要把钱放在里面。
279.完全平方数:https://leetcode.cn/problems/perfect-squares/solutions/823192/dai-ma-sui-xiang-lu-279-wan-quan-ping-fa-9ieo/
300.最长递增子序列:https://leetcode.cn/problems/longest-increasing-subsequence/solutions/2279668/dai-ma-sui-xiang-lu-leetcode300zui-chang-sh5m/
139.单词拆分:
152 乘积最大子数组
32 最长有效括号
多维动态规划:
62 不同路径
64 最小路径和
5 最长回文子串
1143 最长公共子序列
72 编辑距离
能力要求:能自己推DP
图论
目标:理解搜索
核心套路
BFS / DFS
题目
200.岛屿数量
207.课程表
994.腐烂的橘子

浙公网安备 33010602011771号