跳至主要內容

05. LeetCode 题解(按分类排序,推荐 ★★★)

ITCharge大约 78 分钟

LeetCode 题解(按分类排序)

01. 数组

数组基础题目

数组操作题目

题号标题题解标签难度
0189轮转数组open in new windowPythonopen in new window数组、数学、双指针中等
0066加一open in new windowPythonopen in new window数组、数学简单
0724寻找数组的中心下标open in new windowPythonopen in new window数组、前缀和简单
0485最大连续 1 的个数open in new windowPythonopen in new window数组简单
0238除自身以外数组的乘积open in new windowPythonopen in new window数组、前缀和中等

二维数组题目

题号标题题解标签难度
0498对角线遍历open in new windowPythonopen in new window数组、矩阵、模拟中等
0048旋转图像open in new windowPythonopen in new window数组、数学、矩阵中等
0073矩阵置零open in new windowPythonopen in new window数组、哈希表、矩阵中等
0054螺旋矩阵open in new windowPythonopen in new window数组、矩阵、模拟中等
0059螺旋矩阵 IIopen in new windowPythonopen in new window数组、矩阵、模拟中等
0289生命游戏open in new windowPythonopen in new window数组、矩阵、模拟中等

排序算法题目

冒泡排序题目

题号标题题解标签难度
剑指 Offer 45把数组排成最小的数open in new windowPythonopen in new window贪心、字符串、排序中等
0283移动零open in new windowPythonopen in new window数组、双指针简单

选择排序题目

题号标题题解标签难度
0215数组中的第K个最大元素open in new windowPythonopen in new window数组、分治、快速选择、排序、堆(优先队列)中等

插入排序题目

题号标题题解标签难度
0075颜色分类open in new windowPythonopen in new window数组、双指针、排序中等

希尔排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
0506相对名次open in new windowPythonopen in new window数组、排序、堆(优先队列)简单

归并排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
0088合并两个有序数组open in new windowPythonopen in new window数组、双指针、排序简单
剑指 Offer 51数组中的逆序对open in new windowPythonopen in new window树状数组、线段树、数组、二分查找、分治、有序集合、归并排序困难
0315计算右侧小于当前元素的个数open in new windowPythonopen in new window树状数组、线段树、数组、二分查找、分治、有序集合、归并排序困难

快速排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
0169多数元素open in new windowPythonopen in new window数组、哈希表、分治、计数、排序简单

堆排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
0215数组中的第K个最大元素open in new windowPythonopen in new window数组、分治、快速选择、排序、堆(优先队列)中等
剑指 Offer 40最小的k个数open in new windowPythonopen in new window数组、分治、快速选择、排序、堆(优先队列)简单

计数排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
1122数组的相对排序open in new windowPythonopen in new window数组、哈希表、计数排序、排序简单

桶排序题目

题号标题题解标签难度
0912排序数组open in new windowPythonopen in new window数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列)、归并排序中等
0220存在重复元素 IIIopen in new windowPythonopen in new window数组、桶排序、有序集合、排序、滑动窗口困难
0164最大间距open in new windowPythonopen in new window数组、桶排序、基数排序、排序困难

基数排序题目

题号标题题解标签难度
0164最大间距open in new windowPythonopen in new window数组、桶排序、基数排序、排序困难
0561数组拆分open in new windowPythonopen in new window贪心、数组、计数排序、排序简单

其他排序题目

题号标题题解标签难度
0217存在重复元素open in new windowPythonopen in new window数组、哈希表、排序简单
0136只出现一次的数字open in new windowPythonopen in new window位运算、数组简单
0056合并区间open in new windowPythonopen in new window数组、排序中等
0179最大数open in new windowPythonopen in new window贪心、数组、字符串、排序中等
0384打乱数组open in new windowPythonopen in new window数组、数学、随机化中等
剑指 Offer 45把数组排成最小的数open in new windowPythonopen in new window贪心、字符串、排序中等

二分查找题目

二分下标题目

题号标题题解标签难度
0704二分查找open in new windowPythonopen in new window数组、二分查找简单
0374猜数字大小open in new windowPythonopen in new window二分查找、交互简单
0035搜索插入位置open in new windowPythonopen in new window数组、二分查找简单
0034在排序数组中查找元素的第一个和最后一个位置open in new windowPythonopen in new window数组、二分查找中等
0167两数之和 II - 输入有序数组open in new windowPythonopen in new window数组、双指针、二分查找中等
0153寻找旋转排序数组中的最小值open in new windowPythonopen in new window数组、二分查找中等
0154寻找旋转排序数组中的最小值 IIopen in new windowPythonopen in new window数组、二分查找困难
0033搜索旋转排序数组open in new windowPythonopen in new window数组、二分查找中等
0081搜索旋转排序数组 IIopen in new windowPythonopen in new window数组、二分查找中等
0278第一个错误的版本open in new windowPythonopen in new window二分查找、交互简单
0162寻找峰值open in new windowPythonopen in new window数组、二分查找中等
0852山脉数组的峰顶索引open in new windowPythonopen in new window数组、二分查找中等
1095山脉数组中查找目标值open in new windowPythonopen in new window数组、二分查找、交互困难
0744寻找比目标字母大的最小字母open in new windowPythonopen in new window数组、二分查找简单
0004寻找两个正序数组的中位数open in new windowPythonopen in new window数组、二分查找、分治困难
0074搜索二维矩阵open in new windowPythonopen in new window数组、二分查找、矩阵中等
0240搜索二维矩阵 IIopen in new windowPythonopen in new window数组、二分查找、分治、矩阵中等

二分答案题目

题号标题题解标签难度
0069x 的平方根open in new windowPythonopen in new window数学、二分查找简单
0287寻找重复数open in new windowPythonopen in new window位运算、数组、双指针、二分查找中等
0050Pow(x, n)open in new windowPythonopen in new window递归、数学中等
0367有效的完全平方数open in new windowPythonopen in new window数学、二分查找简单
1300转变数组后最接近目标值的数组和open in new windowPythonopen in new window数组、二分查找、排序中等
0400第 N 位数字open in new windowPythonopen in new window数学、二分查找中等

复杂的二分查找问题

题号标题题解标签难度
0875爱吃香蕉的珂珂open in new windowPythonopen in new window数组、二分查找中等
0410分割数组的最大值open in new windowPythonopen in new window贪心、数组、二分查找、动态规划、前缀和困难
0209长度最小的子数组open in new windowPythonopen in new window数组、二分查找、前缀和、滑动窗口中等
0658找到 K 个最接近的元素open in new windowPythonopen in new window数组、双指针、二分查找、排序、滑动窗口、堆(优先队列)中等
0270最接近的二叉搜索树值open in new windowPythonopen in new window树、深度优先搜索、二叉搜索树、二分查找、二叉树简单
0702搜索长度未知的有序数组open in new windowPythonopen in new window数组、二分查找、交互中等
0349两个数组的交集open in new windowPythonopen in new window数组、哈希表、双指针、二分查找、排序简单
0350两个数组的交集 IIopen in new windowPythonopen in new window数组、哈希表、双指针、二分查找、排序简单
0287寻找重复数open in new windowPythonopen in new window位运算、数组、双指针、二分查找中等
0719找出第 K 小的数对距离open in new windowPythonopen in new window数组、双指针、二分查找、排序困难
0259较小的三数之和open in new windowPythonopen in new window数组、双指针、二分查找、排序中等
1011在 D 天内送达包裹的能力open in new windowPythonopen in new window数组、二分查找中等
1482制作 m 束花所需的最少天数open in new windowPythonopen in new window数组、二分查找中等

双指针题目

对撞指针题目

题号标题题解标签难度
0167两数之和 II - 输入有序数组open in new windowPythonopen in new window数组、双指针、二分查找中等
0344反转字符串open in new windowPythonopen in new window双指针、字符串简单
0345反转字符串中的元音字母open in new windowPythonopen in new window双指针、字符串简单
0125验证回文串open in new windowPythonopen in new window双指针、字符串简单
0011盛最多水的容器open in new windowPythonopen in new window贪心、数组、双指针中等
0611有效三角形的个数open in new windowPythonopen in new window贪心、数组、双指针、二分查找、排序中等
0015三数之和open in new windowPythonopen in new window数组、双指针、排序中等
0016最接近的三数之和open in new windowPythonopen in new window数组、双指针、排序中等
0018四数之和open in new windowPythonopen in new window数组、双指针、排序中等
0259较小的三数之和open in new windowPythonopen in new window数组、双指针、二分查找、排序中等
0658找到 K 个最接近的元素open in new windowPythonopen in new window数组、双指针、二分查找、排序、滑动窗口、堆(优先队列)中等
1099小于 K 的两数之和open in new windowPythonopen in new window数组、双指针、二分查找、排序简单
0075颜色分类open in new windowPythonopen in new window数组、双指针、排序中等
0360有序转化数组open in new windowPythonopen in new window数组、数学、双指针、排序中等
0977有序数组的平方open in new windowPythonopen in new window数组、双指针、排序简单
0881救生艇open in new windowPythonopen in new window贪心、数组、双指针、排序中等
0042接雨水open in new windowPythonopen in new window栈、数组、双指针、动态规划、单调栈困难
0443压缩字符串open in new windowPythonopen in new window双指针、字符串中等

快慢指针题目

题号标题题解标签难度
0026删除有序数组中的重复项open in new windowPythonopen in new window数组、双指针简单
0080删除有序数组中的重复项 IIopen in new windowPythonopen in new window数组、双指针中等
0027移除元素open in new windowPythonopen in new window数组、双指针简单
0283移动零open in new windowPythonopen in new window数组、双指针简单
0845数组中的最长山脉open in new windowPythonopen in new window数组、双指针、动态规划、枚举中等
0088合并两个有序数组open in new windowPythonopen in new window数组、双指针、排序简单
0719找出第 K 小的数对距离open in new windowPythonopen in new window数组、双指针、二分查找、排序困难
0334递增的三元子序列open in new windowPythonopen in new window贪心、数组中等
0978最长湍流子数组open in new windowPythonopen in new window数组、动态规划、滑动窗口中等
剑指 Offer 21调整数组顺序使奇数位于偶数前面open in new windowPythonopen in new window数组、双指针、排序简单

分离双指针题目

题号标题题解标签难度
0350两个数组的交集 IIopen in new windowPythonopen in new window数组、哈希表、双指针、二分查找、排序简单
0925长按键入open in new windowPythonopen in new window双指针、字符串简单
0844比较含退格的字符串open in new windowPythonopen in new window栈、双指针、字符串、模拟简单
1229安排会议日程open in new windowPythonopen in new window数组、双指针、排序中等
0415字符串相加open in new windowPythonopen in new window数学、字符串、模拟简单
0392判断子序列open in new windowPythonopen in new window双指针、字符串、动态规划简单

滑动窗口题目

固定长度窗口题目

题号标题题解标签难度
1343大小为 K 且平均值大于等于阈值的子数组数目open in new windowPythonopen in new window数组、滑动窗口中等
0643子数组最大平均数 Iopen in new windowPythonopen in new window数组、滑动窗口简单
1052爱生气的书店老板open in new windowPythonopen in new window数组、滑动窗口中等
1423可获得的最大点数open in new windowPythonopen in new window数组、前缀和、滑动窗口中等
1456定长子串中元音的最大数目open in new windowPythonopen in new window字符串、滑动窗口中等
0567字符串的排列open in new windowPythonopen in new window哈希表、双指针、字符串、滑动窗口中等
1100长度为 K 的无重复字符子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
1151最少交换次数来组合所有的 1open in new windowPythonopen in new window数组、滑动窗口中等
1176健身计划评估open in new windowPythonopen in new window数组、滑动窗口简单
0438找到字符串中所有字母异位词open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0995K 连续位的最小翻转次数open in new windowPythonopen in new window位运算、队列、数组、前缀和、滑动窗口困难
0683K 个关闭的灯泡open in new windowPythonopen in new window树状数组、数组、有序集合、滑动窗口困难
0220存在重复元素 IIIopen in new windowPythonopen in new window数组、桶排序、有序集合、排序、滑动窗口困难
0239滑动窗口最大值open in new windowPythonopen in new window队列、数组、滑动窗口、单调队列、堆(优先队列)困难
0480滑动窗口中位数open in new windowPythonopen in new window数组、哈希表、滑动窗口、堆(优先队列)困难

不定长度窗口题目

题号标题题解标签难度
0674最长连续递增序列open in new windowPythonopen in new window数组简单
0485最大连续 1 的个数open in new windowPythonopen in new window数组简单
0487最大连续1的个数 IIopen in new windowPythonopen in new window数组、动态规划、滑动窗口中等
0076最小覆盖子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口困难
0718最长重复子数组open in new windowPythonopen in new window数组、二分查找、动态规划、滑动窗口、哈希函数、滚动哈希中等
0209长度最小的子数组open in new windowPythonopen in new window数组、二分查找、前缀和、滑动窗口中等
1004最大连续1的个数 IIIopen in new windowPythonopen in new window数组、二分查找、前缀和、滑动窗口中等
1658将 x 减到 0 的最小操作数open in new windowPythonopen in new window数组、哈希表、二分查找、前缀和、滑动窗口中等
0424替换后的最长重复字符open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0003无重复字符的最长子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
1695删除子数组的最大得分open in new windowPythonopen in new window数组、哈希表、滑动窗口中等
1208尽可能使字符串相等open in new windowPythonopen in new window字符串、二分查找、前缀和、滑动窗口中等
1493删掉一个元素以后全为 1 的最长子数组open in new windowPythonopen in new window数组、动态规划、滑动窗口中等
0727最小窗口子序列open in new windowPythonopen in new window字符串、动态规划、滑动窗口困难
0159至多包含两个不同字符的最长子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0340至多包含 K 个不同字符的最长子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0795区间子数组个数open in new windowPythonopen in new window数组、双指针中等
0992K 个不同整数的子数组open in new windowPythonopen in new window数组、哈希表、计数、滑动窗口困难
0713乘积小于 K 的子数组open in new windowPythonopen in new window数组、滑动窗口中等
0904水果成篮open in new windowPythonopen in new window数组、哈希表、滑动窗口中等
1358包含所有三种字符的子字符串数目open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0467环绕字符串中唯一的子字符串open in new windowPythonopen in new window字符串、动态规划中等
1438绝对差不超过限制的最长连续子数组open in new windowPythonopen in new window队列、数组、有序集合、滑动窗口、单调队列、堆(优先队列)中等

02. 链表

链表经典题目

题号标题题解标签难度
0707设计链表open in new windowPythonopen in new window设计、链表中等
0083删除排序链表中的重复元素open in new windowPythonopen in new window链表简单
0082删除排序链表中的重复元素 IIopen in new windowPythonopen in new window链表、双指针中等
0206反转链表open in new windowPythonopen in new window递归、链表简单
0092反转链表 IIopen in new windowPythonopen in new window链表中等
0025K 个一组翻转链表open in new windowPythonopen in new window递归、链表困难
0203移除链表元素open in new windowPythonopen in new window递归、链表简单
0328奇偶链表open in new windowPythonopen in new window链表中等
0234回文链表open in new windowPythonopen in new window栈、递归、链表、双指针简单
0430扁平化多级双向链表open in new windowPythonopen in new window深度优先搜索、链表、双向链表中等
0138复制带随机指针的链表open in new windowPythonopen in new window哈希表、链表中等
0061旋转链表open in new windowPythonopen in new window链表、双指针中等

链表排序题目

题号标题题解标签难度
0148排序链表open in new windowPythonopen in new window链表、双指针、分治、排序、归并排序中等
0021合并两个有序链表open in new windowPythonopen in new window递归、链表简单
0023合并 K 个升序链表open in new windowPythonopen in new window链表、分治、堆(优先队列)、归并排序困难
0147对链表进行插入排序open in new windowPythonopen in new window链表、排序中等

链表双指针题目

题号标题题解标签难度
0141环形链表open in new windowPythonopen in new window哈希表、链表、双指针简单
0142环形链表 IIopen in new windowPythonopen in new window哈希表、链表、双指针中等
0160相交链表open in new windowPythonopen in new window哈希表、链表、双指针简单
0019删除链表的倒数第 N 个结点open in new windowPythonopen in new window链表、双指针中等
0876链表的中间结点open in new windowPythonopen in new window链表、双指针简单
剑指 Offer 22链表中倒数第k个节点open in new windowPythonopen in new window链表、双指针简单
0143重排链表open in new windowPythonopen in new window栈、递归、链表、双指针中等
0002两数相加open in new windowPythonopen in new window递归、链表、数学中等
0445两数相加 IIopen in new windowPythonopen in new window栈、链表、数学中等

03. 堆栈

堆栈基础题目

题号标题题解标签难度
1047删除字符串中的所有相邻重复项open in new windowPythonopen in new window栈、字符串简单
0155最小栈open in new windowPythonopen in new window栈、设计中等
0020有效的括号open in new windowPythonopen in new window栈、字符串简单
0227基本计算器 IIopen in new windowPythonopen in new window栈、数学、字符串中等
0739每日温度open in new windowPythonopen in new window栈、数组、单调栈中等
0150逆波兰表达式求值open in new windowPythonopen in new window栈、数组、数学中等
0232用栈实现队列open in new windowPythonopen in new window栈、设计、队列简单
剑指 Offer 09用两个栈实现队列open in new windowPythonopen in new window栈、设计、队列简单
0394字符串解码open in new windowPythonopen in new window栈、递归、字符串中等
0032最长有效括号open in new windowPythonopen in new window栈、字符串、动态规划困难
0946验证栈序列open in new windowPythonopen in new window栈、数组、模拟中等
剑指 Offer 06从尾到头打印链表open in new windowPythonopen in new window栈、递归、链表、双指针简单
0071简化路径open in new window栈、字符串中等

单调栈

题号标题题解标签难度
0739每日温度open in new windowPythonopen in new window栈、数组、单调栈中等
0496下一个更大元素 Iopen in new windowPythonopen in new window栈、数组、哈希表、单调栈简单
0503下一个更大元素 IIopen in new windowPythonopen in new window栈、数组、单调栈中等
0901股票价格跨度open in new windowPythonopen in new window栈、设计、数据流、单调栈中等
0084柱状图中最大的矩形open in new windowPythonopen in new window栈、数组、单调栈困难
0316去除重复字母open in new windowPythonopen in new window栈、贪心、字符串、单调栈中等
0042接雨水open in new windowPythonopen in new window栈、数组、双指针、动态规划、单调栈困难
0085最大矩形open in new window栈、数组、动态规划、矩阵、单调栈困难
0862和至少为 K 的最短子数组open in new windowPythonopen in new window队列、数组、二分查找、前缀和、滑动窗口、单调队列、堆(优先队列)困难

04. 队列

队列基础题目

题号标题题解标签难度
0622设计循环队列open in new windowPythonopen in new window设计、队列、数组、链表中等
0346数据流中的移动平均值open in new windowPythonopen in new window设计、队列、数组、数据流简单
0225用队列实现栈open in new windowPythonopen in new window栈、设计、队列简单

优先队列题目

题号标题题解标签难度
0703数据流中的第 K 大元素open in new windowPythonopen in new window树、设计、二叉搜索树、二叉树、数据流、堆(优先队列)简单
0347前 K 个高频元素open in new windowPythonopen in new window数组、哈希表、分治、桶排序、计数、快速选择、排序、堆(优先队列)中等
0451根据字符出现频率排序open in new windowPythonopen in new window哈希表、字符串、桶排序、计数、排序、堆(优先队列)中等
0973最接近原点的 K 个点open in new windowPythonopen in new window几何、数组、数学、分治、快速选择、排序、堆(优先队列)中等
1296划分数组为连续数字的集合open in new windowPythonopen in new window贪心、数组、哈希表、排序中等
0239滑动窗口最大值open in new windowPythonopen in new window队列、数组、滑动窗口、单调队列、堆(优先队列)困难
0295数据流的中位数open in new windowPythonopen in new window设计、双指针、数据流、排序、堆(优先队列)困难
0023合并 K 个升序链表open in new windowPythonopen in new window链表、分治、堆(优先队列)、归并排序困难
0218天际线问题open in new windowPythonopen in new window树状数组、线段树、数组、分治、有序集合、扫描线、堆(优先队列)困难

05. 哈希表

哈希表题目

题号标题题解标签难度
0705设计哈希集合open in new windowPythonopen in new window设计、数组、哈希表、链表、哈希函数简单
0706设计哈希映射open in new windowPythonopen in new window设计、数组、哈希表、链表、哈希函数简单
0217存在重复元素open in new windowPythonopen in new window数组、哈希表、排序简单
0219存在重复元素 IIopen in new windowPythonopen in new window数组、哈希表、滑动窗口简单
0220存在重复元素 IIIopen in new windowPythonopen in new window数组、桶排序、有序集合、排序、滑动窗口困难
1941检查是否所有字符出现次数相同open in new windowPythonopen in new window哈希表、字符串、计数简单
0136只出现一次的数字open in new windowPythonopen in new window位运算、数组简单
0383赎金信open in new windowPythonopen in new window哈希表、字符串、计数简单
0349两个数组的交集open in new windowPythonopen in new window数组、哈希表、双指针、二分查找、排序简单
0350两个数组的交集 IIopen in new windowPythonopen in new window数组、哈希表、双指针、二分查找、排序简单
0036有效的数独open in new windowPythonopen in new window数组、哈希表、矩阵中等
0001两数之和open in new windowPythonopen in new window数组、哈希表简单
0015三数之和open in new windowPythonopen in new window数组、双指针、排序中等
0018四数之和open in new windowPythonopen in new window数组、双指针、排序中等
0454四数相加 IIopen in new windowPythonopen in new window数组、哈希表中等
0041缺失的第一个正数open in new windowPythonopen in new window数组、哈希表困难
0128最长连续序列open in new windowPythonopen in new window并查集、数组、哈希表中等
0202快乐数open in new windowPythonopen in new window哈希表、数学、双指针简单
0242有效的字母异位词open in new windowPythonopen in new window哈希表、字符串、排序简单
0205同构字符串open in new windowPythonopen in new window哈希表、字符串简单
0442数组中重复的数据open in new window数组、哈希表中等
剑指 Offer 61扑克牌中的顺子open in new windowPythonopen in new window数组、排序简单
0268丢失的数字open in new windowPythonopen in new window位运算、数组、哈希表、数学、二分查找、排序简单
剑指 Offer 03数组中重复的数字open in new windowPythonopen in new window数组、哈希表、排序简单
0451根据字符出现频率排序open in new windowPythonopen in new window哈希表、字符串、桶排序、计数、排序、堆(优先队列)中等
0049字母异位词分组open in new windowPythonopen in new window数组、哈希表、字符串、排序中等
0599两个列表的最小索引总和open in new windowPythonopen in new window数组、哈希表、字符串简单
0387字符串中的第一个唯一字符open in new windowPythonopen in new window队列、哈希表、字符串、计数简单
0447回旋镖的数量open in new windowPythonopen in new window数组、哈希表、数学中等
0149直线上最多的点数open in new windowPythonopen in new window几何、数组、哈希表、数学困难
0359日志速率限制器open in new windowPythonopen in new window设计、哈希表简单
0811子域名访问计数open in new windowPythonopen in new window数组、哈希表、字符串、计数中等

06. 字符串

字符串基础题目

题号标题题解标签难度
0125验证回文串open in new windowPythonopen in new window双指针、字符串简单
0005最长回文子串open in new windowPythonopen in new window字符串、动态规划中等
0003无重复字符的最长子串open in new windowPythonopen in new window哈希表、字符串、滑动窗口中等
0344反转字符串open in new windowPythonopen in new window双指针、字符串简单
0557反转字符串中的单词 IIIopen in new windowPythonopen in new window双指针、字符串简单
0049字母异位词分组open in new windowPythonopen in new window数组、哈希表、字符串、排序中等
0415字符串相加open in new windowPythonopen in new window数学、字符串、模拟简单
0151反转字符串中的单词open in new windowPythonopen in new window双指针、字符串中等
0043字符串相乘open in new windowPythonopen in new window数学、字符串、模拟中等
0014最长公共前缀open in new windowPythonopen in new window字典树、字符串简单

单模式串匹配题目

题号标题题解标签难度
0028找出字符串中第一个匹配项的下标open in new windowPythonopen in new window双指针、字符串、字符串匹配中等
0459重复的子字符串open in new windowPythonopen in new window字符串、字符串匹配简单
0686重复叠加字符串匹配open in new windowPythonopen in new window字符串、字符串匹配中等
1668最大重复子字符串open in new window字符串、字符串匹配简单
0796旋转字符串open in new windowPythonopen in new window字符串、字符串匹配简单
1408数组中的字符串匹配open in new windowPythonopen in new window数组、字符串、字符串匹配简单
2156查找给定哈希值的子串open in new windowPythonopen in new window字符串、滑动窗口、哈希函数、滚动哈希困难

字典树题目

题号标题题解标签难度
0208实现 Trie (前缀树)open in new windowPythonopen in new window设计、字典树、哈希表、字符串中等
0677键值映射open in new windowPythonopen in new window设计、字典树、哈希表、字符串中等
0648单词替换open in new windowPythonopen in new window字典树、数组、哈希表、字符串中等
0642设计搜索自动补全系统open in new windowPythonopen in new window设计、字典树、字符串、数据流困难
0211添加与搜索单词 - 数据结构设计open in new windowPythonopen in new window深度优先搜索、设计、字典树、字符串中等
0421数组中两个数的最大异或值open in new windowPythonopen in new window位运算、字典树、数组、哈希表中等
0212单词搜索 IIopen in new windowPythonopen in new window字典树、数组、字符串、回溯、矩阵困难
0425单词方块open in new windowPythonopen in new window字典树、数组、字符串、回溯困难
0336回文对open in new windowPythonopen in new window字典树、数组、哈希表、字符串困难
1023驼峰式匹配open in new windowPythonopen in new window字典树、双指针、字符串、字符串匹配中等
0676实现一个魔法字典open in new windowPythonopen in new window设计、字典树、哈希表、字符串中等
0440字典序的第K小数字open in new window字典树困难

07. 树

二叉树的遍历题目

题号标题题解标签难度
0144二叉树的前序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0094二叉树的中序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0145二叉树的后序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0102二叉树的层序遍历open in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0103二叉树的锯齿形层序遍历open in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0107二叉树的层序遍历 IIopen in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0104二叉树的最大深度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0111二叉树的最小深度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0124二叉树中的最大路径和open in new windowPythonopen in new window树、深度优先搜索、动态规划、二叉树困难
0101对称二叉树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0112路径总和open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0113路径总和 IIopen in new windowPythonopen in new window树、深度优先搜索、回溯、二叉树中等
0236二叉树的最近公共祖先open in new windowPythonopen in new window树、深度优先搜索、二叉树中等
0199二叉树的右视图open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树中等
0226翻转二叉树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0958二叉树的完全性检验open in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0572另一棵树的子树open in new window树、深度优先搜索、二叉树、字符串匹配、哈希函数简单
0100相同的树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0116填充每个节点的下一个右侧节点指针open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、链表、二叉树中等
0117填充每个节点的下一个右侧节点指针 IIopen in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、链表、二叉树中等
0297二叉树的序列化与反序列化open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、设计、字符串、二叉树困难
0114二叉树展开为链表open in new window栈、树、深度优先搜索、链表、二叉树中等

二叉树的还原题目

题号标题题解标签难度
0105从前序与中序遍历序列构造二叉树open in new windowPythonopen in new window树、数组、哈希表、分治、二叉树中等
0106从中序与后序遍历序列构造二叉树open in new windowPythonopen in new window树、数组、哈希表、分治、二叉树中等
0889根据前序和后序遍历构造二叉树open in new windowPythonopen in new window树、数组、哈希表、分治、二叉树中等

二叉搜索树题目

题号标题题解标签难度
0098验证二叉搜索树open in new windowPythonopen in new window树、深度优先搜索、二叉搜索树、二叉树中等
0173二叉搜索树迭代器open in new windowPythonopen in new window栈、树、设计、二叉搜索树、二叉树、迭代器中等
0700二叉搜索树中的搜索open in new windowPythonopen in new window树、二叉搜索树、二叉树简单
0701二叉搜索树中的插入操作open in new windowPythonopen in new window树、二叉搜索树、二叉树中等
0450删除二叉搜索树中的节点open in new windowPythonopen in new window树、二叉搜索树、二叉树中等
0703数据流中的第 K 大元素open in new windowPythonopen in new window树、设计、二叉搜索树、二叉树、数据流、堆(优先队列)简单
剑指 Offer 54二叉搜索树的第k大节点open in new windowPythonopen in new window树、深度优先搜索、二叉搜索树、二叉树简单
0230二叉搜索树中第K小的元素open in new window树、深度优先搜索、二叉搜索树、二叉树中等
0235二叉搜索树的最近公共祖先open in new windowPythonopen in new window树、深度优先搜索、二叉搜索树、二叉树中等
0426将二叉搜索树转化为排序的双向链表open in new windowPythonopen in new window栈、树、深度优先搜索、二叉搜索树、链表、二叉树、双向链表中等
0108将有序数组转换为二叉搜索树open in new windowPythonopen in new window树、二叉搜索树、数组、分治、二叉树简单
0110平衡二叉树open in new windowPythonopen in new window树、深度优先搜索、二叉树简单

线段树题目

单点更新题目

题号标题题解标签难度
0303区域和检索 - 数组不可变open in new windowPythonopen in new window设计、数组、前缀和简单
0307区域和检索 - 数组可修改open in new windowPythonopen in new window设计、树状数组、线段树、数组中等
0354俄罗斯套娃信封问题open in new windowPythonopen in new window数组、二分查找、动态规划、排序困难

区间更新题目

题号标题题解标签难度
0370区间加法open in new windowPythonopen in new window数组、前缀和中等
1109航班预订统计open in new windowPythonopen in new window数组、前缀和中等
1450在既定时间做作业的学生人数open in new windowPythonopen in new window数组简单
0673最长递增子序列的个数open in new windowPythonopen in new window树状数组、线段树、数组、动态规划中等
1310子数组异或查询open in new windowPythonopen in new window位运算、数组、前缀和中等
1851包含每个查询的最小区间open in new window数组、二分查找、排序、扫描线、堆(优先队列)困难

区间合并题目

题号标题题解标签难度
0729我的日程安排表 Iopen in new windowPythonopen in new window设计、线段树、二分查找、有序集合中等
0731我的日程安排表 IIopen in new windowPythonopen in new window设计、线段树、二分查找、有序集合中等
0732我的日程安排表 IIIopen in new windowPythonopen in new window设计、线段树、二分查找、有序集合困难

扫描线问题

题号标题题解标签难度
0218天际线问题open in new windowPythonopen in new window树状数组、线段树、数组、分治、有序集合、扫描线、堆(优先队列)困难
0391完美矩形open in new windowPythonopen in new window数组、扫描线困难
0850矩形面积 IIopen in new windowPythonopen in new window线段树、数组、有序集合、扫描线困难

树状数组题目

题号标题题解标签难度
0303区域和检索 - 数组不可变open in new windowPythonopen in new window设计、数组、前缀和简单
0307区域和检索 - 数组可修改open in new windowPythonopen in new window设计、树状数组、线段树、数组中等
0315计算右侧小于当前元素的个数open in new windowPythonopen in new window树状数组、线段树、数组、二分查找、分治、有序集合、归并排序困难
1450在既定时间做作业的学生人数open in new windowPythonopen in new window数组简单
0354俄罗斯套娃信封问题open in new windowPythonopen in new window数组、二分查找、动态规划、排序困难
0673最长递增子序列的个数open in new windowPythonopen in new window树状数组、线段树、数组、动态规划中等
1310子数组异或查询open in new windowPythonopen in new window位运算、数组、前缀和中等
1893检查是否区域内所有整数都被覆盖open in new windowPythonopen in new window数组、哈希表、前缀和简单

并查集题目

题号标题题解标签难度
0990等式方程的可满足性open in new windowPythonopen in new window并查集、图、数组、字符串中等
0547省份数量open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0684冗余连接open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
1319连通网络的操作次数open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0765情侣牵手open in new windowPythonopen in new window贪心、深度优先搜索、广度优先搜索、并查集、图困难
0399除法求值open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图、数组、最短路中等
0959由斜杠划分区域open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
1631最小体力消耗路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列)中等
0778水位上升的泳池中游泳open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列)困难
1202交换字符串中的元素open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、哈希表、字符串中等
0947移除最多的同行或同列石头open in new windowPythonopen in new window深度优先搜索、并查集、图中等
0803打砖块open in new windowPythonopen in new window并查集、数组、矩阵困难
0128最长连续序列open in new windowPythonopen in new window并查集、数组、哈希表中等

08. 图论

图的深度优先搜索题目

题号标题题解标签难度
0797所有可能的路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、回溯中等
0200岛屿数量open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
0695岛屿的最大面积open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
0133克隆图open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、哈希表中等
0494目标和open in new windowPythonopen in new window数组、动态规划、回溯中等
0144二叉树的前序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0094二叉树的中序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0145二叉树的后序遍历open in new windowPythonopen in new window栈、树、深度优先搜索、二叉树简单
0589N 叉树的前序遍历open in new windowPythonopen in new window栈、树、深度优先搜索简单
0590N 叉树的后序遍历open in new windowPythonopen in new window栈、树、深度优先搜索简单
0124二叉树中的最大路径和open in new windowPythonopen in new window树、深度优先搜索、动态规划、二叉树困难
0199二叉树的右视图open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树中等
0543二叉树的直径open in new windowPythonopen in new window树、深度优先搜索、二叉树简单
0662二叉树最大宽度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树中等
0958二叉树的完全性检验open in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0572另一棵树的子树open in new window树、深度优先搜索、二叉树、字符串匹配、哈希函数简单
0100相同的树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0111二叉树的最小深度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0841钥匙和房间open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图中等
0129求根节点到叶节点数字之和open in new windowPythonopen in new window树、深度优先搜索、二叉树中等
0323无向图中连通分量的数目open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0684冗余连接open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0802找到最终的安全状态open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、拓扑排序中等
0785判断二分图open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0886可能的二分法open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0323无向图中连通分量的数目open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
0130被围绕的区域open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
0417太平洋大西洋水流问题open in new windowPythonopen in new window深度优先搜索、广度优先搜索、数组、矩阵中等
1020飞地的数量open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
1254统计封闭岛屿的数目open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
1034边界着色open in new windowPythonopen in new window深度优先搜索、广度优先搜索、数组、矩阵中等
剑指 Offer 13机器人的运动范围open in new windowPythonopen in new window深度优先搜索、广度优先搜索、动态规划中等
0529扫雷游戏open in new window深度优先搜索、广度优先搜索、数组、矩阵中等

图的广度优先搜索题目

题号标题题解标签难度
0797所有可能的路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、回溯中等
0286墙与门open in new windowPythonopen in new window广度优先搜索、数组、矩阵中等
0200岛屿数量open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、矩阵中等
0752打开转盘锁open in new windowPythonopen in new window广度优先搜索、数组、哈希表、字符串中等
0279完全平方数open in new windowPythonopen in new window广度优先搜索、数学、动态规划中等
0133克隆图open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、哈希表中等
0733图像渲染open in new windowPythonopen in new window深度优先搜索、广度优先搜索、数组、矩阵简单
054201 矩阵open in new windowPythonopen in new window广度优先搜索、数组、动态规划、矩阵中等
0322零钱兑换open in new windowPythonopen in new window广度优先搜索、数组、动态规划中等
0323无向图中连通分量的数目open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等
剑指 Offer 13机器人的运动范围open in new windowPythonopen in new window深度优先搜索、广度优先搜索、动态规划中等
0199二叉树的右视图open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树中等
0662二叉树最大宽度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树中等
0958二叉树的完全性检验open in new windowPythonopen in new window树、广度优先搜索、二叉树中等
0572另一棵树的子树open in new window树、深度优先搜索、二叉树、字符串匹配、哈希函数简单
0100相同的树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0111二叉树的最小深度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
剑指 Offer 32 - III从上到下打印二叉树 IIIopen in new windowPythonopen in new window树、广度优先搜索、二叉树中等

图的拓扑排序题目

题号标题题解标签难度
0207课程表open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、拓扑排序中等
0210课程表 IIopen in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、拓扑排序中等
1136并行课程open in new windowPythonopen in new window图、拓扑排序中等
2050并行课程 IIIopen in new windowPythonopen in new window图、拓扑排序、数组、动态规划困难
0802找到最终的安全状态open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、拓扑排序中等
0851喧闹和富有open in new windowPythonopen in new window深度优先搜索、图、拓扑排序、数组中等

图的最小生成树题目

题号标题题解标签难度
1584连接所有点的最小费用open in new window并查集、图、数组、最小生成树中等
1631最小体力消耗路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列)中等
0778水位上升的泳池中游泳open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列)困难

单源最短路径题目

题号标题题解标签难度
0407接雨水 IIopen in new window广度优先搜索、数组、矩阵、堆(优先队列)困难
0743网络延迟时间open in new window深度优先搜索、广度优先搜索、图、最短路、堆(优先队列)中等
0787K 站中转内最便宜的航班open in new window深度优先搜索、广度优先搜索、图、动态规划、最短路、堆(优先队列)中等
1631最小体力消耗路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列)中等
1786从第一个节点出发到最后一个节点的受限路径数open in new window图、拓扑排序、动态规划、最短路、堆(优先队列)中等

多源最短路径题目

题号标题题解标签难度
0815公交路线open in new window广度优先搜索、数组、哈希表困难
1162地图分析open in new window广度优先搜索、数组、动态规划、矩阵中等

次短路径题目

题号标题题解标签难度
2045到达目的地的第二短时间open in new window广度优先搜索、图、最短路困难

差分约束系统

题号标题题解标签难度
0995K 连续位的最小翻转次数open in new windowPythonopen in new window位运算、队列、数组、前缀和、滑动窗口困难
1109航班预订统计open in new windowPythonopen in new window数组、前缀和中等

二分图基础题目

题号标题题解标签难度
0785判断二分图open in new windowPythonopen in new window深度优先搜索、广度优先搜索、并查集、图中等

二分图最大匹配题目

题号标题题解标签难度
LCP 04覆盖open in new window位运算、图、数组、动态规划、状态压缩困难
1947最大兼容性评分和open in new windowPythonopen in new window位运算、数组、动态规划、回溯、状态压缩中等
1595连通两组点的最小成本open in new windowPythonopen in new window位运算、数组、动态规划、状态压缩、矩阵困难

09. 基础算法

枚举算法题目

题号标题题解标签难度
0001两数之和open in new windowPythonopen in new window数组、哈希表简单
0204计数质数open in new windowPythonopen in new window数组、数学、枚举、数论中等
1925统计平方和三元组的数目open in new windowPythonopen in new window数学、枚举简单
1450在既定时间做作业的学生人数open in new windowPythonopen in new window数组简单
1620网络信号最好的坐标open in new window数组、枚举中等
剑指 Offer 57 - II和为s的连续正数序列open in new windowPythonopen in new window数学、双指针、枚举简单
0800相似 RGB 颜色open in new windowPythonopen in new window数学、字符串、枚举简单
0221最大正方形open in new windowPythonopen in new window数组、动态规划、矩阵中等
0560和为 K 的子数组open in new windowPythonopen in new window数组、哈希表、前缀和中等

递归算法题目

题号标题题解标签难度
0344反转字符串open in new windowPythonopen in new window双指针、字符串简单
0024两两交换链表中的节点open in new windowPythonopen in new window递归、链表中等
0118杨辉三角open in new windowPythonopen in new window数组、动态规划简单
0119杨辉三角 IIopen in new windowPythonopen in new window数组、动态规划简单
0206反转链表open in new windowPythonopen in new window递归、链表简单
0092反转链表 IIopen in new windowPythonopen in new window链表中等
0021合并两个有序链表open in new windowPythonopen in new window递归、链表简单
0509斐波那契数open in new windowPythonopen in new window递归、记忆化搜索、数学、动态规划简单
0070爬楼梯open in new windowPythonopen in new window记忆化搜索、数学、动态规划简单
0104二叉树的最大深度open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0124二叉树中的最大路径和open in new windowPythonopen in new window树、深度优先搜索、动态规划、二叉树困难
0226翻转二叉树open in new windowPythonopen in new window树、深度优先搜索、广度优先搜索、二叉树简单
0050Pow(x, n)open in new windowPythonopen in new window递归、数学中等
0779第K个语法符号open in new windowPythonopen in new window位运算、递归、数学中等
0095不同的二叉搜索树 IIopen in new windowPythonopen in new window树、二叉搜索树、动态规划、回溯、二叉树中等
剑指 Offer 62圆圈中最后剩下的数字open in new windowPythonopen in new window递归、数学简单

分治算法题目

题号标题题解标签难度
0004寻找两个正序数组的中位数open in new windowPythonopen in new window数组、二分查找、分治困难
0023合并 K 个升序链表open in new windowPythonopen in new window链表、分治、堆(优先队列)、归并排序困难
0053最大子数组和open in new windowPythonopen in new window数组、分治、动态规划中等
0241为运算表达式设计优先级open in new windowPythonopen in new window递归、记忆化搜索、数学、字符串、动态规划中等
0169多数元素open in new windowPythonopen in new window数组、哈希表、分治、计数、排序简单
0050Pow(x, n)open in new windowPythonopen in new window递归、数学中等
0014最长公共前缀open in new windowPythonopen in new window字典树、字符串简单
剑指 Offer 33二叉搜索树的后序遍历序列open in new windowPythonopen in new window栈、树、二叉搜索树、递归、二叉树、单调栈中等

回溯算法题目

题号标题题解标签难度
0046全排列open in new windowPythonopen in new window数组、回溯中等
0047全排列 IIopen in new windowPythonopen in new window数组、回溯中等
0037解数独open in new windowPythonopen in new window数组、哈希表、回溯、矩阵困难
0022括号生成open in new windowPythonopen in new window字符串、动态规划、回溯中等
0017电话号码的字母组合open in new windowPythonopen in new window哈希表、字符串、回溯中等
0784字母大小写全排列open in new windowPythonopen in new window位运算、字符串、回溯中等
0039组合总和open in new windowPythonopen in new window数组、回溯中等
0040组合总和 IIopen in new windowPythonopen in new window数组、回溯中等
0078子集open in new windowPythonopen in new window位运算、数组、回溯中等
0090子集 IIopen in new windowPythonopen in new window位运算、数组、回溯中等
0473火柴拼正方形open in new windowPythonopen in new window位运算、数组、动态规划、回溯、状态压缩中等
1593拆分字符串使唯一子字符串的数目最大open in new windowPythonopen in new window哈希表、字符串、回溯中等
1079活字印刷open in new windowPythonopen in new window哈希表、字符串、回溯、计数中等
0093复原 IP 地址open in new windowPythonopen in new window字符串、回溯中等
0079单词搜索open in new windowPythonopen in new window数组、回溯、矩阵中等
067924 点游戏open in new window数组、数学、回溯困难

贪心算法题目

题号标题题解标签难度
0455分发饼干open in new windowPythonopen in new window贪心、数组、双指针、排序简单
0860柠檬水找零open in new windowPythonopen in new window贪心、数组简单
0056合并区间open in new windowPythonopen in new window数组、排序中等
0435无重叠区间open in new windowPythonopen in new window贪心、数组、动态规划、排序中等
0452用最少数量的箭引爆气球open in new windowPythonopen in new window贪心、数组、排序中等
0055跳跃游戏open in new windowPythonopen in new window贪心、数组、动态规划中等
0045跳跃游戏 IIopen in new windowPythonopen in new window贪心、数组、动态规划中等
0122买卖股票的最佳时机 IIopen in new windowPythonopen in new window贪心、数组中等
0561数组拆分open in new windowPythonopen in new window贪心、数组、计数排序、排序简单
1710卡车上的最大单元数open in new windowPythonopen in new window贪心、数组、排序简单
1217玩筹码open in new windowPythonopen in new window贪心、数组、数学简单
1247交换字符使得字符串相同open in new windowPythonopen in new window贪心、数学、字符串中等
1400构造 K 个回文字符串open in new windowPythonopen in new window贪心、哈希表、字符串、计数中等
0921使括号有效的最少添加open in new windowPythonopen in new window栈、贪心、字符串中等
1029两地调度open in new windowPythonopen in new window贪心、数组、排序中等
1605给定行和列的和求可行矩阵open in new windowPythonopen in new window贪心、数组、矩阵中等
0135分发糖果open in new windowPythonopen in new window贪心、数组困难
0134加油站open in new windowPythonopen in new window贪心、数组中等
0053最大子数组和open in new windowPythonopen in new window数组、分治、动态规划中等
0376摆动序列open in new windowPythonopen in new window贪心、数组、动态规划中等
0738单调递增的数字open in new windowPythonopen in new window贪心、数学中等
0402移掉 K 位数字open in new window栈、贪心、字符串、单调栈中等
0861翻转矩阵后的得分open in new windowPythonopen in new window贪心、位运算、数组、矩阵中等
0670最大交换open in new window贪心、数学中等

位运算题目

题号标题题解标签难度
0504七进制数open in new windowPythonopen in new window数学简单
0405数字转换为十六进制数open in new windowPythonopen in new window位运算、数学简单
0190颠倒二进制位open in new windowPythonopen in new window位运算、分治简单
1009十进制整数的反码open in new windowPythonopen in new window位运算简单
0191位1的个数open in new windowPythonopen in new window位运算、分治简单
0371两整数之和open in new windowPythonopen in new window位运算、数学中等
0089格雷编码open in new windowPythonopen in new window位运算、数学、回溯中等
0201数字范围按位与open in new windowPythonopen in new window位运算中等
0338比特位计数open in new windowPythonopen in new window位运算、动态规划简单
0136只出现一次的数字open in new windowPythonopen in new window位运算、数组简单
0137只出现一次的数字 IIopen in new windowPythonopen in new window位运算、数组中等
0260只出现一次的数字 IIIopen in new windowPythonopen in new window位运算、数组中等
0268丢失的数字open in new windowPythonopen in new window位运算、数组、哈希表、数学、二分查找、排序简单
1349参加考试的最大学生数open in new windowPythonopen in new window位运算、数组、动态规划、状态压缩、矩阵困难
0645错误的集合open in new window位运算、数组、哈希表、排序简单
0078子集open in new windowPythonopen in new window位运算、数组、回溯中等
0090子集 IIopen in new windowPythonopen in new window位运算、数组、回溯中等

10. 动态规划

动态规划基础题目

题号标题题解标签难度
0509斐波那契数open in new windowPythonopen in new window递归、记忆化搜索、数学、动态规划简单
0070爬楼梯open in new windowPythonopen in new window记忆化搜索、数学、动态规划简单
0062不同路径open in new windowPythonopen in new window数学、动态规划、组合数学中等

记忆化搜索题目

题号标题题解标签难度
1137第 N 个泰波那契数open in new windowPythonopen in new window记忆化搜索、数学、动态规划简单
0375猜数字大小 IIopen in new windowPythonopen in new window数学、动态规划、博弈中等
0494目标和open in new windowPythonopen in new window数组、动态规划、回溯中等
0576出界的路径数open in new windowPythonopen in new window动态规划中等
0087扰乱字符串open in new window字符串、动态规划困难
0403青蛙过河open in new windowPythonopen in new window数组、动态规划困难
0552学生出勤记录 IIopen in new window动态规划困难
0913猫和老鼠open in new window图、拓扑排序、记忆化搜索、数学、动态规划、博弈困难
0329矩阵中的最长递增路径open in new windowPythonopen in new window深度优先搜索、广度优先搜索、图、拓扑排序、记忆化搜索、数组、动态规划、矩阵困难

线性 DP 题目

单串线性 DP 问题

题号标题题解标签难度
0300最长递增子序列open in new windowPythonopen in new window数组、二分查找、动态规划中等
0673最长递增子序列的个数open in new windowPythonopen in new window树状数组、线段树、数组、动态规划中等
0354俄罗斯套娃信封问题open in new windowPythonopen in new window数组、二分查找、动态规划、排序困难
0053最大子数组和open in new windowPythonopen in new window数组、分治、动态规划中等
0152乘积最大子数组open in new windowPythonopen in new window数组、动态规划中等
0918环形子数组的最大和open in new windowPythonopen in new window队列、数组、分治、动态规划、单调队列中等
0198打家劫舍open in new windowPythonopen in new window数组、动态规划中等
0213打家劫舍 IIopen in new windowPythonopen in new window数组、动态规划中等
0740删除并获得点数open in new window数组、哈希表、动态规划中等
13883n 块披萨open in new window贪心、数组、动态规划、堆(优先队列)困难
0873最长的斐波那契子序列的长度open in new windowPythonopen in new window数组、哈希表、动态规划中等
1027最长等差数列open in new window数组、哈希表、二分查找、动态规划中等
1055形成字符串的最短路径open in new window贪心、双指针、字符串中等
0368最大整除子集open in new window数组、数学、动态规划、排序中等
0032最长有效括号open in new windowPythonopen in new window栈、字符串、动态规划困难
0413等差数列划分open in new window数组、动态规划中等
0091解码方法open in new windowPythonopen in new window字符串、动态规划中等
0639解码方法 IIopen in new windowPythonopen in new window字符串、动态规划