跳至主要內容

面试高频 200 题


数组

题号标题题解标签难度力扣频次
189轮转数组[✓]数组 数学 双指针🟠🀄️open in new window 🔗open in new window26
498对角线遍历[✓]数组 矩阵 模拟🟠🀄️open in new window 🔗open in new window43
48旋转图像[✓]数组 数学 矩阵🟠🀄️open in new window 🔗open in new window70
54螺旋矩阵[✓]数组 矩阵 模拟🟠🀄️open in new window 🔗open in new window186
59螺旋矩阵 II[✓]数组 矩阵 模拟🟠🀄️open in new window 🔗open in new window36

链表

题号标题题解标签难度力扣频次
83删除排序链表中的重复元素[✓]链表🟢🀄️open in new window 🔗open in new window54
82删除排序链表中的重复元素 II[✓]链表 双指针🟠🀄️open in new window 🔗open in new window117
206反转链表[✓]递归 链表🟢🀄️open in new window 🔗open in new window575
92反转链表 II[✓]链表🟠🀄️open in new window 🔗open in new window184
25K 个一组翻转链表[✓]递归 链表🔴🀄️open in new window 🔗open in new window332
328奇偶链表[✓]链表🟠🀄️open in new window 🔗open in new window28
234回文链表[✓] 递归 链表 1+🟢🀄️open in new window 🔗open in new window65
138随机链表的复制[✓]哈希表 链表🟠🀄️open in new window 🔗open in new window47
61旋转链表[✓]链表 双指针🟠🀄️open in new window 🔗open in new window38

  • 栈基础
题号标题题解标签难度力扣频次
1047删除字符串中的所有相邻重复项[✓] 字符串🟢🀄️open in new window 🔗open in new window21
155最小栈[✓] 设计🟠🀄️open in new window 🔗open in new window84
20有效的括号[✓] 字符串🟢🀄️open in new window 🔗open in new window207
224基本计算器[✓] 递归 数学 1+🔴🀄️open in new window 🔗open in new window43
227基本计算器 II[✓] 数学 字符串🟠🀄️open in new window 🔗open in new window54
232用栈实现队列[✓] 设计 队列🟢🀄️open in new window 🔗open in new window120
剑指 Offer 9用两个栈实现队列[✓] 设计 队列🟢🀄️open in new window44
394字符串解码[✓] 递归 字符串🟠🀄️open in new window 🔗open in new window66
71简化路径[✓] 字符串🟠🀄️open in new window 🔗open in new window21
  • 单调栈
题号标题题解标签难度力扣频次
739每日温度[✓] 数组 单调栈🟠🀄️open in new window 🔗open in new window46
503下一个更大元素 II[✓] 数组 单调栈🟠🀄️open in new window 🔗open in new window16
42接雨水[✓] 数组 双指针 2+🔴🀄️open in new window 🔗open in new window147
85最大矩形[✓] 数组 动态规划 2+🔴🀄️open in new window 🔗open in new window21

队列

  • 队列基础
题号标题题解标签难度力扣频次
225用队列实现栈[✓] 设计 队列🟢🀄️open in new window 🔗open in new window29
  • 优先队列
题号标题题解标签难度力扣频次
295数据流的中位数[✓]设计 双指针 数据流 2+🔴🀄️open in new window 🔗open in new window26
23合并 K 个升序链表[✓]链表 分治 堆(优先队列) 1+🔴🀄️open in new window 🔗open in new window173

哈希表

题号标题题解标签难度力扣频次
15三数之和[✓]数组 双指针 排序🟠🀄️open in new window 🔗open in new window310
41缺失的第一个正数[✓]数组 哈希表🔴🀄️open in new window 🔗open in new window97
128最长连续序列[✓]并查集 数组 哈希表🟠🀄️open in new window 🔗open in new window56
242有效的字母异位词[✓]哈希表 字符串 排序🟢🀄️open in new window 🔗open in new window17
442数组中重复的数据[✓]数组 哈希表🟠🀄️open in new window 🔗open in new window19
剑指 Offer 61扑克牌中的顺子[✓]数组 排序🟢🀄️open in new window21
剑指 Offer 3数组中重复的数字[✓]数组 哈希表 排序🟢🀄️open in new window16

字符串

  • 字符串基础
题号标题题解标签难度力扣频次
125验证回文串[✓]双指针 字符串🟢🀄️open in new window 🔗open in new window29
5最长回文子串[✓]双指针 字符串 动态规划🟠🀄️open in new window 🔗open in new window222
344反转字符串[✓]双指针 字符串🟢🀄️open in new window 🔗open in new window17
557反转字符串中的单词 III[✓]双指针 字符串🟢🀄️open in new window 🔗open in new window17
151反转字符串中的单词[✓]双指针 字符串🟠🀄️open in new window 🔗open in new window81
43字符串相乘[✓]数学 字符串 模拟🟠🀄️open in new window 🔗open in new window82
  • 单模式串匹配
题号标题题解标签难度力扣频次
459重复的子字符串[✓]字符串 字符串匹配🟢🀄️open in new window 🔗open in new window18
  • 字典树
题号标题题解标签难度力扣频次
208实现 Trie (前缀树)[✓]设计 字典树 哈希表 1+🟠🀄️open in new window 🔗open in new window27
440字典序的第K小数字[✓]字典树🔴🀄️open in new window 🔗open in new window33

  • 二叉树的遍历
题号标题题解标签难度力扣频次
144二叉树的前序遍历[✓] 深度优先搜索 1+🟢🀄️open in new window 🔗open in new window78
145二叉树的后序遍历[✓] 深度优先搜索 1+🟢🀄️open in new window 🔗open in new window36
102二叉树的层序遍历[✓] 广度优先搜索 二叉树🟠🀄️open in new window 🔗open in new window220
103二叉树的锯齿形层序遍历[✓] 广度优先搜索 二叉树🟠🀄️open in new window 🔗open in new window200
101对称二叉树[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window76
112路径总和[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window65
113路径总和 II[✓] 深度优先搜索 回溯 1+🟠🀄️open in new window 🔗open in new window69
236二叉树的最近公共祖先[✓] 深度优先搜索 二叉树🟠🀄️open in new window 🔗open in new window199
199二叉树的右视图[✓] 深度优先搜索 广度优先搜索 1+🟠🀄️open in new window 🔗open in new window118
297二叉树的序列化与反序列化[✓] 深度优先搜索 广度优先搜索 3+🔴🀄️open in new window 🔗open in new window49
114二叉树展开为链表[✓] 深度优先搜索 2+🟠🀄️open in new window 🔗open in new window28
  • 二叉树的还原
题号标题题解标签难度力扣频次
105从前序与中序遍历序列构造二叉树[✓] 数组 哈希表 2+🟠🀄️open in new window 🔗open in new window84
106从中序与后序遍历序列构造二叉树[✓] 数组 哈希表 2+🟠🀄️open in new window 🔗open in new window25
  • 二叉搜索树
题号标题题解标签难度力扣频次
98验证二叉搜索树[✓] 深度优先搜索 二叉搜索树 1+🟠🀄️open in new window 🔗open in new window71
450删除二叉搜索树中的节点[✓] 二叉搜索树 二叉树🟠🀄️open in new window 🔗open in new window33
剑指 Offer 54二叉搜索树的第k大节点[✓] 深度优先搜索 二叉搜索树 1+🟢🀄️open in new window37
230二叉搜索树中第 K 小的元素[✓] 深度优先搜索 二叉搜索树 1+🟠🀄️open in new window 🔗open in new window31
426将二叉搜索树转化为排序的双向链表 🔒[✓] 深度优先搜索 4+🟠🀄️open in new window 🔗open in new window16
110平衡二叉树[✓] 深度优先搜索 二叉树🟢🀄️open in new window 🔗open in new window77

  • 图的深度优先搜索
题号标题题解标签难度力扣频次
200岛屿数量[✓]深度优先搜索 广度优先搜索 并查集 2+🟠🀄️open in new window 🔗open in new window211
695岛屿的最大面积[✓]深度优先搜索 广度优先搜索 并查集 2+🟠🀄️open in new window 🔗open in new window56
94二叉树的中序遍历[✓] 深度优先搜索 1+🟢🀄️open in new window 🔗open in new window124
129求根节点到叶节点数字之和[✓] 深度优先搜索 二叉树🟠🀄️open in new window 🔗open in new window76
124二叉树中的最大路径和[✓] 深度优先搜索 动态规划 1+🔴🀄️open in new window 🔗open in new window129
543二叉树的直径[✓] 深度优先搜索 二叉树🟢🀄️open in new window 🔗open in new window74
662二叉树最大宽度[✓] 深度优先搜索 广度优先搜索 1+🟠🀄️open in new window 🔗open in new window57
958二叉树的完全性检验[✓] 广度优先搜索 二叉树🟠🀄️open in new window 🔗open in new window42
572另一棵树的子树[✓] 深度优先搜索 二叉树 2+🟢🀄️open in new window 🔗open in new window28
100相同的树[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window16
111二叉树的最小深度[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window20
  • 图的广度优先搜索
题号标题题解标签难度力扣频次
322零钱兑换[✓]广度优先搜索 数组 动态规划🟠🀄️open in new window 🔗open in new window84
207课程表[✓]深度优先搜索 广度优先搜索 1+🟠🀄️open in new window 🔗open in new window43
剑指 Offer 32-III从上到下打印二叉树 III[✓] 广度优先搜索 二叉树🟠🀄️open in new window16
  • 图的拓扑排序
题号标题题解标签难度力扣频次
210课程表 II[✓]深度优先搜索 广度优先搜索 1+🟠🀄️open in new window 🔗open in new window19

枚举算法

题号标题题解标签难度力扣频次
1两数之和[✓]数组 哈希表🟢🀄️open in new window 🔗open in new window232
78子集[✓]位运算 数组 回溯🟠🀄️open in new window 🔗open in new window85

递归算法

题号标题题解标签难度力扣频次
24两两交换链表中的节点[✓]递归 链表🟠🀄️open in new window 🔗open in new window50
104二叉树的最大深度[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window77
226翻转二叉树[✓] 深度优先搜索 广度优先搜索 1+🟢🀄️open in new window 🔗open in new window59

分治算法

题号标题题解标签难度力扣频次
169多数元素[✓]数组 哈希表 分治 2+🟢🀄️open in new window 🔗open in new window61
14最长公共前缀[✓]字典树 字符串🟢🀄️open in new window 🔗open in new window58
剑指 Offer 33二叉搜索树的后序遍历序列[✓] 二叉搜索树 4+🟠🀄️open in new window16

回溯算法

题号标题题解标签难度力扣频次
46全排列[✓]数组 回溯🟠🀄️open in new window 🔗open in new window202
47全排列 II[✓]数组 回溯🟠🀄️open in new window 🔗open in new window40
37解数独[✓]数组 哈希表 回溯 1+🔴🀄️open in new window 🔗open in new window18
22括号生成[✓]字符串 动态规划 回溯🟠🀄️open in new window 🔗open in new window105
39组合总和[✓]数组 回溯🟠🀄️open in new window 🔗open in new window68
40组合总和 II[✓]数组 回溯🟠🀄️open in new window 🔗open in new window35
93复原 IP 地址[✓]字符串 回溯🟠🀄️open in new window 🔗open in new window114
79单词搜索[✓]数组 字符串 回溯 1+🟠🀄️open in new window 🔗open in new window38
67924 点游戏数组 数学 回溯🔴🀄️open in new window 🔗open in new window21

贪心算法

题号标题题解标签难度力扣频次
122买卖股票的最佳时机 II[✓]贪心 数组 动态规划🟠🀄️open in new window 🔗open in new window56
55跳跃游戏[✓]贪心 数组 动态规划🟠🀄️open in new window 🔗open in new window38
402移掉 K 位数字 贪心 字符串 1+🟠🀄️open in new window 🔗open in new window44
135分发糖果[✓]贪心 数组🔴🀄️open in new window 🔗open in new window29
134加油站[✓]贪心 数组🟠🀄️open in new window 🔗open in new window20
670最大交换[✓]贪心 数学🟠🀄️open in new window 🔗open in new window17

动态规划

题号标题题解标签难度力扣频次
70爬楼梯[✓]记忆化搜索 数学 动态规划🟢🀄️open in new window 🔗open in new window109
509斐波那契数[✓]递归 记忆化搜索 数学 1+🟢🀄️open in new window 🔗open in new window19
121买卖股票的最佳时机[✓]数组 动态规划🟢🀄️open in new window 🔗open in new window211
518零钱兑换 II[✓]数组 动态规划🟠🀄️open in new window 🔗open in new window35
300最长递增子序列[✓]数组 二分查找 动态规划🟠🀄️open in new window 🔗open in new window163
1143最长公共子序列[✓]字符串 动态规划🟠🀄️open in new window 🔗open in new window120
718最长重复子数组数组 二分查找 动态规划 3+🟠🀄️open in new window 🔗open in new window60
64最小路径和[✓]数组 动态规划 矩阵🟠🀄️open in new window 🔗open in new window68
72编辑距离[✓]字符串 动态规划🟠🀄️open in new window 🔗open in new window127
32最长有效括号[✓] 字符串 动态规划🔴🀄️open in new window 🔗open in new window81
221最大正方形[✓]数组 动态规划 矩阵🟠🀄️open in new window 🔗open in new window68
62不同路径[✓]数学 动态规划 组合数学🟠🀄️open in new window 🔗open in new window55
63不同路径 II[✓]数组 动态规划 矩阵🟠🀄️open in new window 🔗open in new window18
152乘积最大子数组[✓]数组 动态规划🟠🀄️open in new window 🔗open in new window55
198打家劫舍[✓]数组 动态规划🟠🀄️open in new window 🔗open in new window51
213打家劫舍 II数组 动态规划🟠🀄️open in new window 🔗open in new window25
91解码方法字符串 动态规划🟠🀄️open in new window 🔗open in new window28
10正则表达式匹配[✓]递归 字符串 动态规划🔴🀄️open in new window 🔗open in new window26
678有效的括号字符串[✓] 贪心 字符串 1+🟠🀄️open in new window 🔗open in new window21
45跳跃游戏 II[✓]贪心 数组 动态规划🟠🀄️open in new window 🔗open in new window31
673最长递增子序列的个数树状数组 线段树 数组 1+🟠🀄️open in new window 🔗open in new window19
139单词拆分[✓]字典树 记忆化搜索 数组 3+🟠🀄️open in new window 🔗open in new window52
44通配符匹配[✓]贪心 递归 字符串 1+🔴🀄️open in new window 🔗open in new window19
120三角形最小路径和[✓]数组 动态规划🟠🀄️open in new window 🔗open in new window23
96不同的二叉搜索树[✓] 二叉搜索树 数学 2+🟠🀄️open in new window 🔗open in new window24
887鸡蛋掉落数学 二分查找 动态规划🔴🀄️open in new window 🔗open in new window21
97交错字符串[✓]字符串 动态规划🟠🀄️open in new window 🔗open in new window17
516最长回文子序列[✓]字符串 动态规划🟠🀄️open in new window 🔗open in new window17
329矩阵中的最长递增路径深度优先搜索 广度优先搜索 5+🔴🀄️open in new window 🔗open in new window28

位运算

题号标题题解标签难度力扣频次
191位1的个数[✓]位运算 分治🟢🀄️open in new window 🔗open in new window17
268丢失的数字[✓]位运算 数组 哈希表 3+🟢🀄️open in new window 🔗open in new window16

排序算法

  • 冒泡排序
题号标题题解标签难度力扣频次
283移动零[✓]数组 双指针🟢🀄️open in new window 🔗open in new window49
  • 插入排序
题号标题题解标签难度力扣频次
75颜色分类[✓]数组 双指针 排序🟠🀄️open in new window 🔗open in new window33
  • 归并排序
题号标题题解标签难度力扣频次
剑指 Offer 51数组中的逆序对[✓]树状数组 线段树 数组 4+🔴🀄️open in new window37
  • 堆排序
题号标题题解标签难度力扣频次
912排序数组数组 分治 桶排序 5+🟠🀄️open in new window 🔗open in new window16
215数组中的第K个最大元素[✓]数组 分治 快速选择 2+🟠🀄️open in new window 🔗open in new window420
剑指 Offer 40最小的k个数[✓]数组 分治 快速选择 2+🟢🀄️open in new window36
  • 基数排序
题号标题题解标签难度力扣频次
164最大间距数组 桶排序 基数排序 1+🟠🀄️open in new window 🔗open in new window16
  • 其他排序
题号标题题解标签难度力扣频次
136只出现一次的数字[✓]位运算 数组🟢🀄️open in new window 🔗open in new window45
56合并区间[✓]数组 排序🟠🀄️open in new window 🔗open in new window125
179最大数贪心 数组 字符串 1+🟠🀄️open in new window 🔗open in new window51
384打乱数组数组 数学 随机化🟠🀄️open in new window 🔗open in new window28
剑指 Offer 45把数组排成最小的数[✓]贪心 字符串 排序🟠🀄️open in new window18
  • 链表排序
题号标题题解标签难度力扣频次
148排序链表[✓]链表 双指针 分治 2+🟠🀄️open in new window 🔗open in new window111
21合并两个有序链表[✓]递归 链表🟢🀄️open in new window 🔗open in new window242

二分查找

  • 二分下标
题号标题题解标签难度力扣频次
704二分查找[✓]数组 二分查找🟢🀄️open in new window 🔗open in new window120
34在排序数组中查找元素的第一个和最后一个位置[✓]数组 二分查找🟠🀄️open in new window 🔗open in new window67
153寻找旋转排序数组中的最小值[✓]数组 二分查找🟠🀄️open in new window 🔗open in new window49
154寻找旋转排序数组中的最小值 II[✓]数组 二分查找🔴🀄️open in new window 🔗open in new window16
33搜索旋转排序数组[✓]数组 二分查找🟠🀄️open in new window 🔗open in new window220
162寻找峰值[✓]数组 二分查找🟠🀄️open in new window 🔗open in new window60
4寻找两个正序数组的中位数[✓]数组 二分查找 分治🔴🀄️open in new window 🔗open in new window117
74搜索二维矩阵[✓]数组 二分查找 矩阵🟠🀄️open in new window 🔗open in new window35
240搜索二维矩阵 II[✓]数组 二分查找 分治 1+🟠🀄️open in new window 🔗open in new window61
  • 二分答案
题号标题题解标签难度力扣频次
69x 的平方根[✓]数学 二分查找🟢🀄️open in new window 🔗open in new window109
287寻找重复数[✓]位运算 数组 双指针 1+🟠🀄️open in new window 🔗open in new window25
50Pow(x, n)[✓]递归 数学🟠🀄️open in new window 🔗open in new window37
400第 N 位数字[✓]数学 二分查找🟠🀄️open in new window 🔗open in new window23
  • 复杂的二分查找问题
题号标题题解标签难度力扣频次
209长度最小的子数组[✓]数组 二分查找 前缀和 1+🟠🀄️open in new window 🔗open in new window49
349两个数组的交集数组 哈希表 双指针 2+🟢🀄️open in new window 🔗open in new window22

双指针

  • 对撞指针
题号标题题解标签难度力扣频次
611有效三角形的个数[✓]贪心 数组 双指针 2+🟠🀄️open in new window 🔗open in new window20
16最接近的三数之和[✓]数组 双指针 排序🟠🀄️open in new window 🔗open in new window29
11盛最多水的容器[✓]贪心 数组 双指针🟠🀄️open in new window 🔗open in new window43
剑指 Offer 21调整数组顺序使奇数位于偶数前面[✓]数组 双指针 排序🟢🀄️open in new window30
443压缩字符串[✓]双指针 字符串🟠🀄️open in new window 🔗open in new window18
  • 快慢指针
题号标题题解标签难度力扣频次
26删除有序数组中的重复项[✓]数组 双指针🟢🀄️open in new window 🔗open in new window35
88合并两个有序数组[✓]数组 双指针 排序🟢🀄️open in new window 🔗open in new window204
  • 分离双指针
题号标题题解标签难度力扣频次
415字符串相加[✓]数学 字符串 模拟🟢🀄️open in new window 🔗open in new window166
  • 链表双指针
题号标题题解标签难度力扣频次
141环形链表[✓]哈希表 链表 双指针🟢🀄️open in new window 🔗open in new window210
142环形链表 II[✓]哈希表 链表 双指针🟠🀄️open in new window 🔗open in new window148
160相交链表[✓]哈希表 链表 双指针🟢🀄️open in new window 🔗open in new window176
19删除链表的倒数第 N 个结点[✓]链表 双指针🟠🀄️open in new window 🔗open in new window129
剑指 Offer 22链表中倒数第k个节点[✓]链表 双指针🟢🀄️open in new window95
143重排链表[✓] 递归 链表 1+🟠🀄️open in new window 🔗open in new window148
2两数相加[✓]递归 链表 数学🟠🀄️open in new window 🔗open in new window106
445两数相加 II[✓] 链表 数学🟠🀄️open in new window 🔗open in new window28

滑动窗口

  • 固定长度窗口
题号标题题解标签难度力扣频次
239滑动窗口最大值[✓]队列 数组 滑动窗口 2+🔴🀄️open in new window 🔗open in new window98
  • 不定长度窗口
题号标题题解标签难度力扣频次
3无重复字符的最长子串[✓]哈希表 字符串 滑动窗口🟠🀄️open in new window 🔗open in new window642
76最小覆盖子串[✓]哈希表 字符串 滑动窗口🔴🀄️open in new window 🔗open in new window87
862和至少为 K 的最短子数组[✓]队列 数组 二分查找 4+🔴🀄️open in new window 🔗open in new window16
1004最大连续1的个数 III[✓]数组 二分查找 前缀和 1+🟠🀄️open in new window 🔗open in new window22

补充

  • 设计数据结构
题号标题题解标签难度力扣频次
146LRU 缓存[✓]设计 哈希表 链表 1+🟠🀄️open in new window 🔗open in new window525
460LFU 缓存设计 哈希表 链表 1+🔴🀄️open in new window 🔗open in new window45
  • 数学
题号标题题解标签难度力扣频次
7整数反转[✓]数学🟠🀄️open in new window 🔗open in new window37
9回文数[✓]数学🟢🀄️open in new window 🔗open in new window27
剑指 Offer 62圆圈中最后剩下的数字[✓]递归 数学🟢🀄️open in new window30
168Excel 表列名称数学 字符串🟢🀄️open in new window 🔗open in new window20
  • 模拟
题号标题题解标签难度力扣频次
8字符串转换整数 (atoi)[✓]字符串🟠🀄️open in new window 🔗open in new window106
165比较版本号双指针 字符串🟠🀄️open in new window 🔗open in new window96
468验证IP地址字符串🟠🀄️open in new window 🔗open in new window48
86分隔链表[✓]链表 双指针🟠🀄️open in new window 🔗open in new window18
  • 前缀和
题号标题题解标签难度力扣频次
560和为 K 的子数组[✓]数组 哈希表 前缀和🟠🀄️open in new window 🔗open in new window49
  • 思维锻炼
题号标题题解标签难度力扣频次
31下一个排列[✓]数组 双指针🟠🀄️open in new window 🔗open in new window111
556下一个更大元素 III数学 双指针 字符串🟠🀄️open in new window 🔗open in new window19
470用 Rand7() 实现 Rand10()数学 拒绝采样 概率与统计 1+🟠🀄️open in new window 🔗open in new window68