目录

高频算法题

目录

刷题方式

1.初次
+ 5-10分钟审题:有想法直接做,没有就去看题解
+ 记忆默写优质解法、了解时间复杂度、空间复杂度

2. 再遇
+ 完整做题
+ 多解法比较、优化

3. 次日回顾
+ 原题的不同解法答题
+ 类似题练习 * 2

4. 一周后回顾
+ 做题、专项训练*3

5. 面试前一周
+ 查漏补缺
+ 回顾及热身
  • LeetcodeTop汇总各大互联网公司容易考察的高频leetcode题:https://github.com/afatcoder/LeetcodeTop
  • 用动画的形式呈现解LeetCode题目的思路:https://github.com/MisterBooo/LeetCodeAnimation

知识点:

1.排序算法:快速、归并、计数算法
2.搜索算法:回溯、递归、剪枝
3.动态规划:背包问题、最长子序列、计数问题
4.图论:最短路径、最小生成树、网络流建模
5.基础技巧:分治、倍增、二分法、贪心算法

数据结构:
数组、链表
栈、队列
树、图
哈希表
大小根堆,可并堆
字符串:字典树、后缀树
知识点难度题目题号
二叉树简单二叉树的中序遍历94
二叉树简单二叉树的前序遍历144
二叉树简单对称二叉树101
二叉树简单二叉树的直径543
二叉树简单翻转二叉树226
二叉树中等二叉树的层序遍历102
二叉树中等二叉树的锯齿形层次遍历103
二叉树中等二叉树的最近公共祖先236
二叉树中等验证二叉搜索树98
二叉树中等路径总和②113
二叉树困难二叉树中的最大路径和124
链表简单反转链表206
链表简单环形链表141
链表简单相交链表160
链表中等反转链表②92
链表中等环形链表②142
链表中等重排链表143
链表中等删除链表的倒数第N个节点19
链表中等排序链表148
链表中等两数相加2
链表困难K个一组翻转链表25
栈&单调栈&队列简单有效的括号20
栈&单调栈&队列简单最小栈155
栈&单调栈&队列困难接雨水42
栈&单调栈&队列困难滑动窗口最大值239
栈&单调栈&队列困难最长有效括号32
哈希表简单多数元素169
二分查找简单x的平方根69
二分查找中等搜索旋转排序数组33
二分查找中等搜索二维矩阵②240
动态规划DP简单买卖股票的最佳时机121
动态规划DP简单爬楼梯70
动态规划DP中等最长上升子序列300
动态规划DP中等最小路径和64
动态规划DP中等最长重复子数组718
动态规划DP中等最大正方形221
动态规划DP中等零钱兑换322
回溯/DFS中等岛屿数量200
回溯/DFS中等全排列46
回溯/DFS中等组合总和39
堆(优先队列)中等数组中的第K个最大元素215
堆(优先队列)困难合并K个排序链表23
排序&归并中等手撕快速排序补充题4
字符串处理简单字符串相加415
字符串处理简单比较版本号165
字符串处理中等翻转字符串里的单词151
字符串处理中等字符串相乘43
字符串/滑动窗口中等重复字符的最长子串3
字符串/动态规划中等最长回文子串5
数组&双指针简单合并两个有序数组88
数组&双指针中等三数之和15
数组&双指针中等螺旋矩阵54
数组&双指针中等合并区间56
数组&双指针中等下一个排列31
数组&双指针中等旋转图像48
数组&双指针困难缺失的第一个正数41
知识点难度题目链接
二叉树简单二叉树的最大深度https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
二叉树简单平衡二叉树https://leetcode-cn.com/problems/balanced-binary-tree/
二叉树简单路径总和https://leetcode-cn.com/problems/path-sum/
二叉树简单求根节点到叶节点数字之和https://leetcode-cn.com/problems/sum-root-to-leaf-numbers/
二叉树中等完全二叉树的节点个数https://leetcode-cn.com/problems/count-complete-tree-nodes/
二叉树中等二叉搜索树的第k大节点https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/
二叉树中等二叉树的右视图https://leetcode-cn.com/problems/binary-tree-right-side-view/
二叉树中等从前序与中序遍历序列构造二叉树https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
二叉树中等从中序与后序遍历序列构造二叉树https://leetcode-cn.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/
链表简单合并两个有序链表https://leetcode-cn.com/problems/merge-two-sorted-lists/
链表简单删除链表的节点https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof/
链表简单链表中倒数第k个节点https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/
链表简单从尾到头打印链表https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/
链表简单回文链表https://leetcode-cn.com/problems/palindrome-linked-list/
链表中等删除排序链表中的重复元素 IIhttps://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/
栈&单调栈&队列简单用栈实现队列https://leetcode-cn.com/problems/implement-queue-using-stacks/
栈&单调栈&队列简单设计循环队列https://leetcode-cn.com/problems/design-circular-queue/
栈&单调栈&队列中等简化路径https://leetcode-cn.com/problems/simplify-path/
栈&单调栈&队列中等基本计算器 IIhttps://leetcode-cn.com/problems/basic-calculator-ii/
栈&单调栈&队列中等扁平化嵌套列表迭代器https://leetcode-cn.com/problems/flatten-nested-list-iterator/
栈&单调栈&队列中等移掉 K 位数字https://leetcode-cn.com/problems/remove-k-digits/
栈&单调栈&队列中等去除重复字母https://leetcode-cn.com/problems/remove-duplicate-letters/
栈&单调栈&队列困难直方图的水量https://leetcode-cn.com/problems/volume-of-histogram-lcci/
栈&单调栈&队列困难柱状图中最大的矩形https://leetcode-cn.com/problems/largest-rectangle-in-histogram/
栈&单调栈&队列困难计算器https://leetcode-cn.com/problems/calculator-lcci/
哈希表简单两数之和https://leetcode-cn.com/problems/two-sum/
哈希表简单数组中重复的数字https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/
哈希表中等连续数组https://leetcode-cn.com/problems/contiguous-array/
哈希表中等森林中的兔子https://leetcode-cn.com/problems/rabbits-in-forest/
哈希表中等字母异位词分组https://leetcode-cn.com/problems/group-anagrams/
二分查找简单二分查找https://leetcode-cn.com/problems/binary-search/
二分查找中等寻找旋转排序数组中的最小值https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/
二分查找中等寻找旋转排序数组中的最小值 IIhttps://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/
二分查找困难分割数组的最大值https://leetcode-cn.com/problems/split-array-largest-sum/
二分查找困难寻找两个正序数组的中位数https://leetcode-cn.com/problems/median-of-two-sorted-arrays/
动态规划DP简单最大子数组和https://leetcode-cn.com/problems/maximum-subarray/
动态规划DP中等乘积最大子数组https://leetcode-cn.com/problems/maximum-product-subarray/
动态规划DP中等打家劫舍 IIhttps://leetcode-cn.com/problems/house-robber-ii/
动态规划DP中等目标和https://leetcode-cn.com/problems/target-sum/
动态规划DP中等整数拆分https://leetcode-cn.com/problems/integer-break/
动态规划DP中等最长公共子序列https://leetcode-cn.com/problems/longest-common-subsequence/
动态规划DP困难吃掉 N 个橘子的最少天数https://leetcode-cn.com/problems/minimum-number-of-days-to-eat-n-oranges/
动态规划DP困难编辑距离https://leetcode-cn.com/problems/edit-distance/
动态规划DP困难不同的子序列https://leetcode-cn.com/problems/distinct-subsequences/
动态规划DP困难正则表达式匹配https://leetcode-cn.com/problems/regular-expression-matching/
动态规划DP困难统计全 1 子矩形https://leetcode-cn.com/problems/count-submatrices-with-all-ones/
回溯/DFS中等子集https://leetcode-cn.com/problems/subsets/
回溯/DFS中等括号生成https://leetcode-cn.com/problems/generate-parentheses/
回溯/DFS中等复原 IP 地址https://leetcode-cn.com/problems/restore-ip-addresses/
回溯/DFS中等字符串的排列https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/
回溯/DFS中等被围绕的区域https://leetcode-cn.com/problems/surrounded-regions/
回溯/DFS困难24 点游戏https://leetcode-cn.com/problems/24-game/
回溯/DFS困难八皇后https://leetcode-cn.com/problems/eight-queens-lcci/
堆(优先队列)简单最小K个数https://leetcode-cn.com/problems/smallest-k-lcci/
堆(优先队列)简单最小的k个数https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/
排序&归并中等排序数组https://leetcode-cn.com/problems/sort-an-array/
排序&归并简单合并排序的数组https://leetcode-cn.com/problems/sorted-merge-lcci/
排序&归并困难数组中的逆序对https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof/
字符串处理简单重复的子字符串https://leetcode-cn.com/problems/repeated-substring-pattern/
字符串处理简单反转字符串中的单词 IIIhttps://leetcode-cn.com/problems/reverse-words-in-a-string-iii/
字符串处理简单字符串压缩https://leetcode-cn.com/problems/compress-string-lcci/
字符串处理中等字符串转换整数 (atoi)https://leetcode-cn.com/problems/string-to-integer-atoi/
字符串处理困难最小覆盖子串https://leetcode-cn.com/problems/minimum-window-substring/
数组&双指针简单汇总区间https://leetcode-cn.com/problems/summary-ranges/
数组&双指针中等轮转数组https://leetcode-cn.com/problems/rotate-array/
数组&双指针中等最大交换https://leetcode-cn.com/problems/maximum-swap/
位运算简单只出现一次的数字https://leetcode-cn.com/problems/single-number/
系统设计(缓存)中等LRU 缓存https://leetcode-cn.com/problems/lru-cache-lcci/
系统设计(缓存)困难LFU 缓存https://leetcode-cn.com/problems/lfu-cache/
随机&概率中等打乱数组https://leetcode-cn.com/problems/shuffle-an-array/
随机&概率中等用 Rand7() 实现 Rand10()https://leetcode-cn.com/problems/implement-rand10-using-rand7/

HduOJ练习

acm新生训练分类100题(杭电OJ网址 acm.hdu.edu.cn)
1、基本输入输出题(共8题)
1089——1096【√】
2、基础训练题(共33题)
2000——2032【√2000-2009】
3、数学题(共10题)
1008、1108、1061、2035、1425、1021、1005、1205、1071、1215
4、递推求解(共5题)
2050、2046、1297、1465、2045
5、贪心(共8题)
1009、1052、2037、1050、1045、1051、1053、1789
6、动态规划(共26题)
2084、1257、1160、1087、1159、1421、1058、1003、1025、1059、
1069、1074、1078、1114、1158、1165、1176、1203、1208、1331、
1355、1414、1428、1579、1723、2602

2025:字符串与字符
2026:字符串与字符
2027:字符串、字符与数组
数组:2018 2020 2022 2023 2027 2028 2032 2034

时间复杂度

增长趋势:输入规模 n 变大时,算法需要的操作次数随 n 怎么增长。只看最高阶项,忽略常数。

快速记忆

复杂度通俗理解典型算法
O(1)O(1)做固定几步,跟数据量无关随机访问数组
O(log⁡n)O(\log n)每次砍一半二分查找
O(n)O(n)从头到尾扫一遍单循环遍历
O(nlog⁡n)O(n\log n)一层循环 × 一层二分快排、归并、堆排
O(n2)O(n^2)双重循环冒泡排序
O(2n)O(2^n)每多一个元素工作量翻倍子集暴力枚举
O(n!)O(n!)全排列暴力枚举全排列回溯无剪枝

补充两个容易混淆点

  1. O(log⁡n)O(\log n) 底数不写,因为只是常数倍差异,复杂度分析忽略常数。log⁡2n\log_2n、log⁡10n\log_{10}n 都记作 O(log⁡n)O(\log n)。
  2. O(n)O(\sqrt{n}) 平方根复杂度:介于 O(log⁡n)O(\log n) 和 O(n)O(n) 之间,比如枚举到根号n判断质数。
← 返回技术