From f8e865d5d86e37b1ee93a2f2a2f2dfd6918ca1d2 Mon Sep 17 00:00:00 2001 From: Yogesh Kumar Singh Date: Thu, 18 Jun 2026 08:25:03 +0530 Subject: [PATCH] Update README.md --- README.md | 852 +++++++++++++++++++++++------------------------------- 1 file changed, 354 insertions(+), 498 deletions(-) diff --git a/README.md b/README.md index 4b5116573e..0f394b36f0 100644 --- a/README.md +++ b/README.md @@ -1,499 +1,355 @@ -[![Star History Chart](https://api.star-history.com/svg?repos=labuladong/fucking-algorithm&type=Date)](https://star-history.com/#labuladong/fucking-algorithm&Date) - -English version is on [labuladong.online](https://labuladong.online/algo/en/) too. Just enjoy:) - -# labuladong 的算法笔记 - -本仓库总共 60 多篇原创文章,都是基于 LeetCode 的题目,涵盖了所有题型和技巧,而且一定要做到**举一反三,通俗易懂**,绝不是简单的代码堆砌,后面有目录。 - -我先吐槽几句。**刷题刷题,刷的是题,培养的是思维,本仓库的目的就是传递这种算法思维**。我要是只写一个包含 LeetCode 题目代码的仓库,有个锤子用?没有思路解释,没有思维框架,顶多写个时间复杂度,那玩意一眼就能看出来。 - -只想要答案的话很容易,题目评论区五花八门的答案,动不动就秀 python 一行代码解决,有那么多人点赞。问题是,你去做算法题,是去学习编程语言的奇技淫巧的,还是学习算法思维的呢?你的快乐,到底源自复制别人的一行代码通过测试,已完成题目 +1,还是源自自己通过逻辑推理和算法框架不看答案写出解法? - -网上总有大佬喷我,说我写的东西太基础,要么说不能借助框架思维来学习算法。我只能说大家刷算法就是找工作吃饭的,不是打竞赛的,我也是一路摸爬滚打过来的,我们要的是清楚明白有所得,不是故弄玄虚无所指。 - -不想办法做到通俗易懂,难道要上来先把《算法导论》吹上天,然后把人家都心怀敬仰地劝退? - -**做啥事情做多了,都能发现套路的,我把各种算法套路框架总结出来,相信可以帮助其他人少走弯路**。我这个纯靠自学的小童鞋,花了一年时间刷题和总结,自己写了一份算法小抄,后面有目录,这里就不废话了。 - -## 在开始学习之前 - -**1、先给本仓库点个 star,满足一下我的虚荣心**,文章质量绝对值你一个 star。我还在继续创作,给我一点继续写文的动力,感谢。 - -**2、建议收藏我的在线网站,每篇文章开头都有对应的力扣题目链接,可以边看文章边刷题,一共可以手把手带你刷 500 道题目**: - -2024 最新地址:https://labuladong.online/algo/ - -~~GitHub Pages 地址:https://labuladong.online/algo/~~ - -~~Gitee Pages 地址:https://labuladong.gitee.io/algo/~~ - -## labuladong 刷题全家桶简介 - -### 一、算法可视化面板 - -我的算法网站、所有配套插件都集成了一个算法可视化工具,可以对数据结构和递归过程进行可视化,大幅降低理解算法的难度。几乎每道题目的解法代码都有对应的可视化面板,具体参见下方介绍。 - - -### 二、学习网站 - -内容当然是我的系列算法教程中最核心的部分,我的算法教程都发布在网站 [labuladong.online](https://labuladong.online/algo/) 上,相信你会未来会在这里花费大量的学习时间,而不是仅仅加入收藏夹~ - -![](https://labuladong.github.io/pictures/简介/web_intro1.jpg) - -### 三、Chrome 插件 - -**主要功能**:Chrome 插件可以在中文版力扣或英文版 LeetCode 上快捷查看我的「题解」或「思路」,并添加了题目和算法技巧之间的引用关系,可以和我的网站/公众号/课程联动,给我的读者提供最丝滑的刷题体验。安装使用手册见下方目录。 - -![](https://labuladong.github.io/pictures/简介/chrome_intro.jpg) - - -### 四、vscode 插件 - -**主要功能**:和 Chrome 插件功能基本相同,习惯在 vscode 上刷题的读者可以使用该插件。安装使用手册见下方目录。 - -![](https://labuladong.github.io/pictures/简介/vs_intro.jpg) - - -### 五、Jetbrains 插件 - -**主要功能**:和 Chrome 插件功能基本相同,习惯在 Jetbrains 家的 IDE(PyCharm/Intellij/Goland 等)上刷题的读者可以使用该插件。安装使用手册见下方目录。 - -![](https://labuladong.github.io/pictures/简介/jb_intro.jpg) - - -最后祝大家学习愉快,在题海中自在遨游! - - -# 文章目录 - - - - -* [本站简介](https://labuladong.online/algo/home/) - -* [针对初学和速成的学习规划](https://labuladong.online/algo/menu/plan/) - * [速成目录学习规划](https://labuladong.online/algo/intro/quick-learning-plan/) - * [完整目录学习规划](https://labuladong.online/algo/intro/beginner-learning-plan/) - * [算法刷题的重点和坑](https://labuladong.online/algo/intro/how-to-learn-algorithms/) - * [习题章节的练习/复习方法](https://labuladong.online/algo/intro/how-to-practice/) - -* [配套学习工具使用指南](https://labuladong.online/algo/menu/tools/) - * [AI 助教随时答疑](https://labuladong.online/algo/intro/ai-assistant/) - * [算法可视化面板使用说明](https://labuladong.online/algo/intro/visualize/) - * [算法游戏玩法及汇总](https://labuladong.online/algo/intro/game/) - * [配套 Chrome 刷题插件](https://labuladong.online/algo/intro/chrome/) - * [配套 vscode/cursor 刷题插件](https://labuladong.online/algo/intro/vscode/) - * [配套 JetBrains 刷题插件](https://labuladong.online/algo/intro/jetbrains/) - * [本站付费会员](https://labuladong.online/algo/intro/site-vip/) - -* [入门:编程语言基础及练习](https://labuladong.online/algo/menu/) - * [本章导读](https://labuladong.online/algo/intro/programming-language-basic/) - * [C++ 语言基础](https://labuladong.online/algo/programming-language-basic/cpp/) - * [Java 语言基础](https://labuladong.online/algo/programming-language-basic/java/) - * [Golang 语言基础](https://labuladong.online/algo/programming-language-basic/golang/) - * [Python 语言基础](https://labuladong.online/algo/programming-language-basic/python/) - * [JavaScript 语言基础](https://labuladong.online/algo/intro/js/) - * [力扣/LeetCode 解题须知](https://labuladong.online/algo/intro/leetcode/) - * [编程语言刷题实践](https://labuladong.online/algo/programming-language-basic/lc-practice/) - * [ACM 模式代码模板](https://labuladong.online/algo/intro/acm-mode/) - -* [基础:数据结构及排序精讲](https://labuladong.online/algo/menu/quick-start/) - * [本章导读](https://labuladong.online/algo/intro/data-structure-basic/) - * [时间空间复杂度入门](https://labuladong.online/algo/intro/complexity-basic/) - - * [手把手带你实现动态数组](https://labuladong.online/algo/menu/dynamic-array/) - * [数组(顺序存储)基本原理](https://labuladong.online/algo/data-structure-basic/array-basic/) - * [动态数组代码实现](https://labuladong.online/algo/data-structure-basic/array-implement/) - - * [手把手带你实现单/双链表](https://labuladong.online/algo/menu/linked-list/) - * [链表(链式存储)基本原理](https://labuladong.online/algo/data-structure-basic/linkedlist-basic/) - * [链表代码实现](https://labuladong.online/algo/data-structure-basic/linkedlist-implement/) - * [【游戏】实现贪吃蛇](https://labuladong.online/algo/game/snake/) - - * [数组链表的种种变换](https://labuladong.online/algo/menu/arr-linked/) - * [环形数组技巧及实现](https://labuladong.online/algo/data-structure-basic/cycle-array/) - * [跳表核心原理](https://labuladong.online/algo/data-structure-basic/skip-list-basic/) - * [位图原理及实现](https://labuladong.online/algo/data-structure-basic/bitmap/) - - * [手把手带你实现队列/栈](https://labuladong.online/algo/menu/queue-stack/) - * [队列/栈基本原理](https://labuladong.online/algo/data-structure-basic/queue-stack-basic/) - * [用链表实现队列/栈](https://labuladong.online/algo/data-structure-basic/linked-queue-stack/) - * [用数组实现队列/栈](https://labuladong.online/algo/data-structure-basic/array-queue-stack/) - * [双端队列(Deque)原理及实现](https://labuladong.online/algo/data-structure-basic/deque-implement/) - - * [哈希表的原理及实现](https://labuladong.online/algo/menu/hash-table/) - * [哈希表核心原理](https://labuladong.online/algo/data-structure-basic/hashmap-basic/) - * [用拉链法实现哈希表](https://labuladong.online/algo/data-structure-basic/hashtable-chaining/) - * [线性探查法的两个难点](https://labuladong.online/algo/data-structure-basic/linear-probing-key-point/) - * [线性探查法的两种代码实现](https://labuladong.online/algo/data-structure-basic/linear-probing-code/) - * [哈希集合的原理及代码实现](https://labuladong.online/algo/data-structure-basic/hash-set/) - - * [哈希表结构的种种变换](https://labuladong.online/algo/menu/hash-table-variation/) - * [用链表加强哈希表(LinkedHashMap)](https://labuladong.online/algo/data-structure-basic/hashtable-with-linked-list/) - * [用数组加强哈希表(ArrayHashMap)](https://labuladong.online/algo/data-structure-basic/hashtable-with-array/) - * [布隆过滤器原理及实现](https://labuladong.online/algo/data-structure-basic/bloom-filter/) - - * [二叉树结构及遍历](https://labuladong.online/algo/menu/binary-tree/) - * [二叉树基础及常见类型](https://labuladong.online/algo/data-structure-basic/binary-tree-basic/) - * [二叉树的递归/层序遍历](https://labuladong.online/algo/data-structure-basic/binary-tree-traverse-basic/) - * [DFS 和 BFS 的适用场景](https://labuladong.online/algo/data-structure-basic/use-case-of-dfs-bfs/) - * [多叉树的递归/层序遍历](https://labuladong.online/algo/data-structure-basic/n-ary-tree-traverse-basic/) - - * [二叉树结构的种种变换](https://labuladong.online/algo/menu/binary-tree/) - * [二叉搜索树的应用及可视化](https://labuladong.online/algo/data-structure-basic/tree-map-basic/) - * [红黑树的完美平衡及可视化](https://labuladong.online/algo/data-structure-basic/rbtree-basic/) - * [Trie/字典树/前缀树原理及可视化](https://labuladong.online/algo/data-structure-basic/trie-map-basic/) - * [二叉堆核心原理及可视化](https://labuladong.online/algo/data-structure-basic/binary-heap-basic/) - * [二叉堆/优先级队列代码实现](https://labuladong.online/algo/data-structure-basic/binary-heap-implement/) - * [线段树核心原理及可视化](https://labuladong.online/algo/data-structure-basic/segment-tree-basic/) - * [数据压缩和霍夫曼树](https://labuladong.online/algo/data-structure-basic/huffman-tree/) - * [正在更新 ing](https://labuladong.online/algo/intro/updating/) - - * [图结构基础及算法概览](https://labuladong.online/algo/menu/graph-theory/) - * [图论中的基本术语](https://labuladong.online/algo/data-structure-basic/graph-terminology/) - * [图结构的通用代码实现](https://labuladong.online/algo/data-structure-basic/graph-basic/) - * [图结构的 DFS/BFS 遍历](https://labuladong.online/algo/data-structure-basic/graph-traverse-basic/) - * [欧拉图和一笔画游戏](https://labuladong.online/algo/data-structure-basic/eulerian-graph/) - * [图结构最短路径算法概览](https://labuladong.online/algo/data-structure-basic/graph-shortest-path/) - * [最小生成树算法概览](https://labuladong.online/algo/data-structure-basic/graph-minimum-spanning-tree/) - * [Union Find 并查集原理](https://labuladong.online/algo/data-structure-basic/union-find-basic/) - * [正在更新 ing](https://labuladong.online/algo/intro/updating/) - - * [十大排序算法原理及可视化](https://labuladong.online/algo/menu/sorting/) - * [本章导读](https://labuladong.online/algo/intro/sorting/) - * [排序算法的关键指标](https://labuladong.online/algo/data-structure-basic/sort-basic/) - * [选择排序所面临的问题](https://labuladong.online/algo/data-structure-basic/select-sort/) - * [拥有稳定性:冒泡排序](https://labuladong.online/algo/data-structure-basic/bubble-sort/) - * [运用逆向思维:插入排序](https://labuladong.online/algo/data-structure-basic/insertion-sort/) - * [突破 O(N^2):希尔排序](https://labuladong.online/algo/data-structure-basic/shell-sort/) - * [妙用二叉树前序位置:快速排序](https://labuladong.online/algo/data-structure-basic/quick-sort/) - * [妙用二叉树后序位置:归并排序](https://labuladong.online/algo/data-structure-basic/merge-sort/) - * [二叉堆结构的运用:堆排序](https://labuladong.online/algo/data-structure-basic/heap-sort/) - * [全新的排序原理:计数排序](https://labuladong.online/algo/data-structure-basic/counting-sort/) - * [博采众长:桶排序](https://labuladong.online/algo/data-structure-basic/bucket-sort/) - * [基数排序(Radix Sort)](https://labuladong.online/algo/data-structure-basic/radix-sort/) - - * [正在更新 ing](https://labuladong.online/algo/intro/updating/) - - -* [第零章、核心刷题框架汇总](https://labuladong.online/algo/menu/core/) - * [本章导读](https://labuladong.online/algo/intro/core-intro/) - * [学习数据结构和算法的框架思维](https://labuladong.online/algo/essential-technique/algorithm-summary/) - * [双指针技巧秒杀七道链表题目](https://labuladong.online/algo/essential-technique/linked-list-skills-summary/) - * [双指针技巧秒杀七道数组题目](https://labuladong.online/algo/essential-technique/array-two-pointers-summary/) - * [滑动窗口算法核心代码模板](https://labuladong.online/algo/essential-technique/sliding-window-framework/) - * [二叉树系列算法核心纲领](https://labuladong.online/algo/essential-technique/binary-tree-summary/) - * [一个视角 + 两种思维模式搞定递归](https://labuladong.online/algo/essential-technique/understand-recursion/) - * [动态规划解题套路框架](https://labuladong.online/algo/essential-technique/dynamic-programming-framework/) - * [回溯算法解题套路框架](https://labuladong.online/algo/essential-technique/backtrack-framework/) - * [BFS 算法解题套路框架](https://labuladong.online/algo/essential-technique/bfs-framework/) - * [回溯算法秒杀所有排列/组合/子集问题](https://labuladong.online/algo/essential-technique/permutation-combination-subset-all-in-one/) - * [贪心算法解题套路框架](https://labuladong.online/algo/essential-technique/greedy/) - * [分治算法解题套路框架](https://labuladong.online/algo/essential-technique/divide-and-conquer/) - * [算法时空复杂度分析实用指南](https://labuladong.online/algo/essential-technique/complexity-analysis/) - - -* [第一章、经典数据结构算法](https://labuladong.online/algo/menu/ds/) - * [手把手刷链表算法](https://labuladong.online/algo/menu/linked-list/) - * [双指针技巧秒杀七道链表题目](https://labuladong.online/algo/essential-technique/linked-list-skills-summary/) - * [链表双指针经典习题](https://labuladong.online/algo/problem-set/linkedlist-two-pointers/) - * [单链表的花式反转方法汇总](https://labuladong.online/algo/data-structure/reverse-linked-list-recursion/) - * [如何判断回文链表](https://labuladong.online/algo/data-structure/palindrome-linked-list/) - - * [手把手刷数组算法](https://labuladong.online/algo/menu/array/) - * [双指针技巧秒杀七道数组题目](https://labuladong.online/algo/essential-technique/array-two-pointers-summary/) - * [【游戏】消消乐游戏](https://labuladong.online/algo/game/match-three/) - * [二维数组的花式遍历技巧](https://labuladong.online/algo/practice-in-action/2d-array-traversal-summary/) - * [数组双指针经典习题](https://labuladong.online/algo/problem-set/array-two-pointers/) - * [【游戏】生命游戏](https://labuladong.online/algo/game/life-game/) - * [一个方法团灭 nSum 问题](https://labuladong.online/algo/practice-in-action/nsum/) - * [小而美的算法技巧:前缀和数组](https://labuladong.online/algo/data-structure/prefix-sum/) - * [前缀和技巧经典习题](https://labuladong.online/algo/problem-set/perfix-sum/) - * [小而美的算法技巧:差分数组](https://labuladong.online/algo/data-structure/diff-array/) - * [滑动窗口算法核心代码模板](https://labuladong.online/algo/essential-technique/sliding-window-framework/) - * [滑动窗口算法经典习题](https://labuladong.online/algo/problem-set/sliding-window/) - * [滑动窗口延伸:Rabin Karp 字符匹配算法](https://labuladong.online/algo/practice-in-action/rabinkarp/) - * [二分搜索算法核心代码模板](https://labuladong.online/algo/essential-technique/binary-search-framework/) - * [二分搜索左闭右开写法](https://labuladong.online/algo/essential-technique/binary-search-left-open/) - * [实际运用二分搜索时的思维框架](https://labuladong.online/algo/frequency-interview/binary-search-in-action/) - * [二分搜索算法经典习题](https://labuladong.online/algo/problem-set/binary-search/) - * [带权重的随机选择算法](https://labuladong.online/algo/frequency-interview/random-pick-with-weight/) - * [田忌赛马背后的算法决策](https://labuladong.online/algo/practice-in-action/advantage-shuffle/) - - - * [经典队列/栈算法](https://labuladong.online/algo/menu/queue-stack/) - * [队列实现栈以及栈实现队列](https://labuladong.online/algo/data-structure/stack-queue/) - * [栈的经典习题](https://labuladong.online/algo/problem-set/stack/) - * [括号类问题汇总](https://labuladong.online/algo/problem-set/parentheses/) - * [队列的经典习题](https://labuladong.online/algo/problem-set/queue/) - * [单调栈算法模板解决三道例题](https://labuladong.online/algo/data-structure/monotonic-stack/) - * [单调栈的几种变体及经典习题](https://labuladong.online/algo/problem-set/monotonic-stack/) - * [单调队列结构解决滑动窗口问题](https://labuladong.online/algo/data-structure/monotonic-queue/) - * [单调队列的通用实现及经典习题](https://labuladong.online/algo/problem-set/monotonic-queue/) - - * [手把手刷二叉树算法](https://labuladong.online/algo/menu/binary-tree/) - * [二叉树系列算法核心纲领](https://labuladong.online/algo/essential-technique/binary-tree-summary/) - * [二叉树心法(思路篇)](https://labuladong.online/algo/data-structure/binary-tree-part1/) - * [二叉树心法(构造篇)](https://labuladong.online/algo/data-structure/binary-tree-part2/) - * [二叉树心法(后序篇)](https://labuladong.online/algo/data-structure/binary-tree-part3/) - * [二叉树心法(序列化篇)](https://labuladong.online/algo/data-structure/serialize-and-deserialize-binary-tree/) - * [二叉搜索树心法(特性篇)](https://labuladong.online/algo/data-structure/bst-part1/) - * [二叉搜索树心法(基操篇)](https://labuladong.online/algo/data-structure/bst-part2/) - * [二叉搜索树心法(构造篇)](https://labuladong.online/algo/data-structure/bst-part3/) - * [二叉搜索树心法(后序篇)](https://labuladong.online/algo/data-structure/bst-part4/) - - * [二叉树算法习题汇总](https://labuladong.online/algo/menu/100-bt/) - * [本章导读](https://labuladong.online/algo/intro/binary-tree-practice/) - * [用「遍历」思维解题 I](https://labuladong.online/algo/problem-set/binary-tree-traverse-i/) - * [用「遍历」思维解题 II](https://labuladong.online/algo/problem-set/binary-tree-traverse-ii/) - * [用「遍历」思维解题 III](https://labuladong.online/algo/problem-set/binary-tree-traverse-iii/) - * [用「分解问题」思维解题 I](https://labuladong.online/algo/problem-set/binary-tree-divide-i/) - * [用「分解问题」思维解题 II](https://labuladong.online/algo/problem-set/binary-tree-divide-ii/) - * [同时运用两种思维解题](https://labuladong.online/algo/problem-set/binary-tree-combine-two-view/) - * [利用后序位置解题 I](https://labuladong.online/algo/problem-set/binary-tree-post-order-i/) - * [利用后序位置解题 II](https://labuladong.online/algo/problem-set/binary-tree-post-order-ii/) - * [利用后序位置解题 III](https://labuladong.online/algo/problem-set/binary-tree-post-order-iii/) - * [运用层序遍历解题 I](https://labuladong.online/algo/problem-set/binary-tree-level-i/) - * [运用层序遍历解题 II](https://labuladong.online/algo/problem-set/binary-tree-level-ii/) - * [二叉搜索树经典例题 I](https://labuladong.online/algo/problem-set/bst1/) - * [二叉搜索树经典例题 II](https://labuladong.online/algo/problem-set/bst2/) - - * [二叉树的拓展延伸](https://labuladong.online/algo/menu/more-bt/) - * [拓展:最近公共祖先系列解题框架](https://labuladong.online/algo/practice-in-action/lowest-common-ancestor-summary/) - * [拓展:如何计算完全二叉树的节点数](https://labuladong.online/algo/data-structure/count-complete-tree-nodes/) - * [拓展:惰性展开多叉树](https://labuladong.online/algo/data-structure/flatten-nested-list-iterator/) - * [拓展:归并排序详解及应用](https://labuladong.online/algo/practice-in-action/merge-sort/) - * [拓展:快速排序详解及应用](https://labuladong.online/algo/practice-in-action/quick-sort/) - * [拓展:用栈模拟递归迭代遍历二叉树](https://labuladong.online/algo/data-structure/iterative-traversal-binary-tree/) - - * [经典数据结构设计](https://labuladong.online/algo/menu/design/) - * [算法就像搭乐高:手撸 LRU 算法](https://labuladong.online/algo/data-structure/lru-cache/) - * [算法就像搭乐高:手撸 LFU 算法](https://labuladong.online/algo/frequency-interview/lfu/) - * [常数时间删除/查找数组中的任意元素](https://labuladong.online/algo/data-structure/random-set/) - * [哈希表更多习题](https://labuladong.online/algo/problem-set/hash-table/) - * [优先级队列经典习题](https://labuladong.online/algo/problem-set/binary-heap/) - * [TreeMap/TreeSet 代码实现](https://labuladong.online/algo/data-structure-basic/tree-map-implement/) - * [基本线段树的代码实现](https://labuladong.online/algo/data-structure/segment-tree-implement/) - * [优化:实现动态线段树](https://labuladong.online/algo/data-structure/segment-tree-dynamic/) - * [优化:实现懒更新线段树](https://labuladong.online/algo/data-structure/segment-tree-lazy-update/) - * [线段树经典习题](https://labuladong.online/algo/problem-set/segment-tree/) - * [Trie 树代码实现](https://labuladong.online/algo/data-structure/trie-implement/) - * [Trie 树算法习题](https://labuladong.online/algo/problem-set/trie/) - * [设计考场座位分配算法](https://labuladong.online/algo/frequency-interview/exam-room/) - * [更多经典设计习题](https://labuladong.online/algo/problem-set/ds-design/) - * [实现霍夫曼编码压缩算法](https://labuladong.online/algo/data-structure/huffman-tree-implementation/) - * [一致性哈希算法的原理及实现](https://labuladong.online/algo/data-structure/consistent-hashing/) - * [拓展:如何实现一个计算器](https://labuladong.online/algo/data-structure/implement-calculator/) - * [拓展:两个二叉堆实现中位数算法](https://labuladong.online/algo/practice-in-action/find-median-from-data-stream/) - * [拓展:数组去重问题(困难版)](https://labuladong.online/algo/frequency-interview/remove-duplicate-letters/) - - - * [经典图算法](https://labuladong.online/algo/menu/graph/) - * [二分图判定算法](https://labuladong.online/algo/data-structure/bipartite-graph/) - * [Hierholzer 算法寻找欧拉路径](https://labuladong.online/algo/data-structure/eulerian-graph-hierholzer/) - * [欧拉路径经典习题](https://labuladong.online/algo/problem-set/eulerian-path/) - * [环检测算法](https://labuladong.online/algo/data-structure/cycle-detection/) - * [拓扑排序算法](https://labuladong.online/algo/data-structure/topological-sort/) - * [Union-Find 并查集算法](https://labuladong.online/algo/data-structure/union-find/) - * [并查集经典习题](https://labuladong.online/algo/problem-set/union-find/) - * [Dijkstra 算法核心原理及实现](https://labuladong.online/algo/data-structure/dijkstra/) - * [Dijkstra 拓展:带限制的最短路问题](https://labuladong.online/algo/data-structure/dijkstra-follow-up/) - * [Dijkstra 算法经典习题](https://labuladong.online/algo/problem-set/dijkstra/) - * [A* 算法核心原理及实现](https://labuladong.online/algo/data-structure/a-star/) - * [Kruskal 最小生成树算法](https://labuladong.online/algo/data-structure/kruskal/) - * [Prim 最小生成树算法](https://labuladong.online/algo/data-structure/prim/) - -* [第二章、经典暴力搜索算法](https://labuladong.online/algo/menu/braute-force-search/) - * [DFS/回溯算法](https://labuladong.online/algo/menu/dfs/) - * [回溯算法解题套路框架](https://labuladong.online/algo/essential-technique/backtrack-framework/) - * [回溯算法实践:数独和 N 皇后问题](https://labuladong.online/algo/practice-in-action/sudoku-nqueue/) - * [【游戏】实现数独作弊器](https://labuladong.online/algo/game/sudoku/) - * [回溯算法秒杀所有排列/组合/子集问题](https://labuladong.online/algo/essential-technique/permutation-combination-subset-all-in-one/) - * [解答回溯算法/DFS算法的若干疑问](https://labuladong.online/algo/essential-technique/backtrack-vs-dfs/) - * [一文秒杀所有岛屿题目](https://labuladong.online/algo/frequency-interview/island-dfs-summary/) - * [【游戏】扫雷 II](https://labuladong.online/algo/game/minesweeper-ii/) - * [球盒模型:回溯算法穷举的两种视角](https://labuladong.online/algo/practice-in-action/two-views-of-backtrack/) - * [回溯算法实践:括号生成](https://labuladong.online/algo/practice-in-action/generate-parentheses/) - * [回溯算法实践:集合划分](https://labuladong.online/algo/practice-in-action/partition-to-k-equal-sum-subsets/) - * [回溯算法经典习题 I](https://labuladong.online/algo/problem-set/backtrack-i/) - * [回溯算法经典习题 II](https://labuladong.online/algo/problem-set/backtrack-ii/) - * [回溯算法经典习题 III](https://labuladong.online/algo/problem-set/backtrack-iii/) - - * [BFS 算法](https://labuladong.online/algo/menu/bfs/) - * [BFS 算法解题套路框架](https://labuladong.online/algo/essential-technique/bfs-framework/) - * [【游戏】求解迷宫](https://labuladong.online/algo/game/maze/) - * [【游戏】华容道游戏](https://labuladong.online/algo/game/huarong-road/) - * [【游戏】连连看游戏](https://labuladong.online/algo/game/connect-two/) - * [BFS 经典习题 I](https://labuladong.online/algo/problem-set/bfs/) - * [BFS 经典习题 II](https://labuladong.online/algo/problem-set/bfs-ii/) - -* [第三章、经典动态规划算法](https://labuladong.online/algo/menu/dp/) - * [动态规划基本技巧](https://labuladong.online/algo/menu/dp-basic/) - * [动态规划解题套路框架](https://labuladong.online/algo/essential-technique/dynamic-programming-framework/) - * [动态规划设计:最长递增子序列](https://labuladong.online/algo/dynamic-programming/longest-increasing-subsequence/) - * [base case 和备忘录的初始值怎么定?](https://labuladong.online/algo/dynamic-programming/memo-fundamental/) - * [动态规划穷举的两种视角](https://labuladong.online/algo/dynamic-programming/two-views-of-dp/) - * [动态规划和回溯算法的思维转换](https://labuladong.online/algo/dynamic-programming/word-break/) - * [对动态规划进行空间压缩](https://labuladong.online/algo/dynamic-programming/space-optimization/) - * [最优子结构原理和 dp 数组遍历方向](https://labuladong.online/algo/dynamic-programming/faq-summary/) - - * [子序列类型问题](https://labuladong.online/algo/menu/subsequence/) - * [经典动态规划:编辑距离](https://labuladong.online/algo/dynamic-programming/edit-distance/) - * [动态规划设计:最大子数组](https://labuladong.online/algo/dynamic-programming/maximum-subarray/) - * [经典动态规划:最长公共子序列](https://labuladong.online/algo/dynamic-programming/longest-common-subsequence/) - * [动态规划之子序列问题解题模板](https://labuladong.online/algo/dynamic-programming/subsequence-problem/) - - * [背包类型问题](https://labuladong.online/algo/menu/knapsack/) - * [经典动态规划:0-1 背包问题](https://labuladong.online/algo/dynamic-programming/knapsack1/) - * [经典动态规划:子集背包问题](https://labuladong.online/algo/dynamic-programming/knapsack2/) - * [经典动态规划:完全背包问题](https://labuladong.online/algo/dynamic-programming/knapsack3/) - * [背包问题的变体:目标和](https://labuladong.online/algo/dynamic-programming/target-sum/) - - * [用动态规划玩游戏](https://labuladong.online/algo/menu/dp-game/) - * [动态规划之最小路径和](https://labuladong.online/algo/dynamic-programming/minimum-path-sum/) - * [动态规划帮我通关了《魔塔》](https://labuladong.online/algo/dynamic-programming/magic-tower/) - * [动态规划帮我通关了《辐射4》](https://labuladong.online/algo/dynamic-programming/freedom-trail/) - * [旅游省钱大法:加权最短路径](https://labuladong.online/algo/dynamic-programming/cheap-travel/) - * [多源最短路径:Floyd 算法](https://labuladong.online/algo/data-structure/floyd/) - * [经典动态规划:正则表达式](https://labuladong.online/algo/dynamic-programming/regular-expression-matching/) - * [经典动态规划:高楼扔鸡蛋](https://labuladong.online/algo/dynamic-programming/egg-drop/) - * [经典动态规划:戳气球](https://labuladong.online/algo/dynamic-programming/burst-balloons/) - * [经典动态规划:博弈问题](https://labuladong.online/algo/dynamic-programming/game-theory/) - * [一个方法团灭 LeetCode 打家劫舍问题](https://labuladong.online/algo/dynamic-programming/house-robber/) - * [一个方法团灭 LeetCode 股票买卖问题](https://labuladong.online/algo/dynamic-programming/stock-problem-summary/) - - * [动态规划习题集](https://labuladong.online/algo/menu/dp-basic/) - * [打家劫舍问题模式](https://labuladong.online/algo/problem-set/rob-house/) - * [背包问题经典习题](https://labuladong.online/algo/problem-set/knapsack/) - * [动态规划经典习题 I](https://labuladong.online/algo/problem-set/dynamic-programming-i/) - * [动态规划经典习题 II](https://labuladong.online/algo/problem-set/dynamic-programming-ii/) - - * [贪心类型问题](https://labuladong.online/algo/menu/greedy/) - * [贪心算法解题套路框架](https://labuladong.online/algo/essential-technique/greedy/) - * [老司机加油算法](https://labuladong.online/algo/frequency-interview/gas-station-greedy/) - * [贪心算法之区间调度问题](https://labuladong.online/algo/frequency-interview/interval-scheduling/) - * [扫描线技巧:安排会议室](https://labuladong.online/algo/frequency-interview/scan-line-technique/) - * [剪视频剪出一个贪心算法](https://labuladong.online/algo/frequency-interview/cut-video/) - - -* [第四章、其他常见算法技巧](https://labuladong.online/algo/menu/other/) - * [数学运算技巧](https://labuladong.online/algo/menu/math/) - * [一行代码就能解决的算法题](https://labuladong.online/algo/frequency-interview/one-line-solutions/) - * [常用的位操作](https://labuladong.online/algo/frequency-interview/bitwise-operation/) - * [必知必会数学技巧](https://labuladong.online/algo/essential-technique/math-techniques-summary/) - * [【游戏】扫雷游戏地图生成器](https://labuladong.online/algo/game/minesweeper/) - * [谈谈游戏中的随机算法](https://labuladong.online/algo/frequency-interview/random-algorithm/) - * [讲两道常考的阶乘算法题](https://labuladong.online/algo/frequency-interview/factorial-problems/) - * [如何高效寻找素数](https://labuladong.online/algo/frequency-interview/print-prime-number/) - * [如何同时寻找缺失和重复的元素](https://labuladong.online/algo/frequency-interview/mismatch-set/) - * [几个反直觉的概率问题](https://labuladong.online/algo/frequency-interview/probability-problem/) - * [数学技巧相关习题](https://labuladong.online/algo/problem-set/math-tricks/) - - * [经典面试题](https://labuladong.online/algo/menu/interview/) - * [如何高效解决接雨水问题](https://labuladong.online/algo/frequency-interview/trapping-rain-water/) - * [一文秒杀所有丑数系列问题](https://labuladong.online/algo/frequency-interview/ugly-number-summary/) - * [一个方法解决三道区间问题](https://labuladong.online/algo/practice-in-action/interval-problem-summary/) - * [谁能想到,斗地主也能玩出算法](https://labuladong.online/algo/practice-in-action/split-array-into-consecutive-subsequences/) - * [烧饼排序算法](https://labuladong.online/algo/frequency-interview/pancake-sorting/) - * [字符串乘法计算](https://labuladong.online/algo/practice-in-action/multiply-strings/) - * [如何判定完美矩形](https://labuladong.online/algo/frequency-interview/perfect-rectangle/) - -* [更多内容](https://labuladong.online/algo/menu/appendix/) - * [计算机基础知识](https://labuladong.online/algo/menu/computer-basics/) - * [AI 时代的前端开发入门教程](https://labuladong.online/algo/computer-science/frontend-introduction/) - * [现代加密技术入门](https://labuladong.online/algo/computer-science/encryption-intro/) - * [深入理解 session 和 cookie](https://labuladong.online/algo/other-skills/session-and-cookie/) - * [深入理解 JSON Web Token (JWT)](https://labuladong.online/algo/computer-science/how-jwt-works/) - * [认证和授权的区别与联系](https://labuladong.online/algo/computer-science/authentication-vs-authorization/) - * [深入理解 OAuth 2.0 授权框架](https://labuladong.online/algo/computer-science/oauth2-explained/) - * [OAuth 2.0 和 OIDC 认证](https://labuladong.online/algo/computer-science/oidc/) - * [OAuth 2.0 与 PKCE](https://labuladong.online/algo/computer-science/pkce/) - * [深入理解单点登录 (SSO)](https://labuladong.online/algo/computer-science/sso/) - * [深入理解数字证书和 CA](https://labuladong.online/algo/computer-science/certificate-and-ca/) - * [深入理解 TLS 密钥协商](https://labuladong.online/algo/computer-science/tls-key-exchange/) - * [深入理解 mTLS 双向认证](https://labuladong.online/algo/computer-science/mtls/) - * [初识 Linux 文件系统](https://labuladong.online/algo/other-skills/linux-file-system/) - * [Linux的进程、线程、文件描述符是什么](https://labuladong.online/algo/other-skills/linux-process/) - * [Linux 管道符的坑](https://labuladong.online/algo/other-skills/linux-pipeline/) - * [Linux shell 的使用技巧](https://labuladong.online/algo/other-skills/linux-shell/) - * [浅谈存储系统:LSM 树设计原理](https://labuladong.online/algo/other-skills/lsm-tree/) - * [正在更新 ing](https://labuladong.online/algo/intro/updating/) - - * [设计模式](https://labuladong.online/algo/menu/design-pattern/) - * [单例模式](https://labuladong.online/algo/design-pattern/singleton/) - * [工厂方法模式](https://labuladong.online/algo/design-pattern/factory-method/) - * [抽象工厂模式](https://labuladong.online/algo/design-pattern/abstract-factory/) - * [生成器模式](https://labuladong.online/algo/design-pattern/builder/) - * [原型模式](https://labuladong.online/algo/design-pattern/prototype/) - * [适配器模式](https://labuladong.online/algo/design-pattern/adapter/) - * [组合模式](https://labuladong.online/algo/design-pattern/composite/) - * [装饰模式](https://labuladong.online/algo/design-pattern/decorator/) - * [桥接模式](https://labuladong.online/algo/design-pattern/bridge/) - * [观察者模式](https://labuladong.online/algo/design-pattern/observer/) - * [策略模式](https://labuladong.online/algo/design-pattern/strategy/) - * [正在更新 ing](https://labuladong.online/algo/intro/updating/) - - - - -# 感谢如下大佬参与翻译 - -按照昵称字典序排名: - -[ABCpril](https://github.com/ABCpril), -[andavid](https://github.com/andavid), -[bryceustc](https://github.com/bryceustc), -[build2645](https://github.com/build2645), -[CarrieOn](https://github.com/CarrieOn), -[cooker](https://github.com/xiaochuhub), -[Dong Wang](https://github.com/Coder2Programmer), -[ExcaliburEX](https://github.com/ExcaliburEX), -[floatLig](https://github.com/floatLig), -[ForeverSolar](https://github.com/foreversolar), -[Fulin Li](https://fulinli.github.io/), -[Funnyyanne](https://github.com/Funnyyanne), -[GYHHAHA](https://github.com/GYHHAHA), -[Hi_archer](https://hiarcher.top/), -[Iruze](https://github.com/Iruze), -[Jieyixia](https://github.com/Jieyixia), -[Justin](https://github.com/Justin-YGG), -[Kevin](https://github.com/Kevin-free), -[Lrc123](https://github.com/Lrc123), -[lriy](https://github.com/lriy), -[Lyjeeq](https://github.com/Lyjeeq), -[MasonShu](https://greenwichmt.github.io/), -[Master-cai](https://github.com/Master-cai), -[miaoxiaozui2017](https://github.com/miaoxiaozui2017), -[natsunoyoru97](https://github.com/natsunoyoru97), -[nettee](https://github.com/nettee), -[PaperJets](https://github.com/PaperJets), -[qy-yang](https://github.com/qy-yang), -[realism0331](https://github.com/realism0331), -[SCUhzs](https://github.com/brucecat), -[Seaworth](https://github.com/Seaworth), -[shazi4399](https://github.com/shazi4399), -[ShuozheLi](https://github.com/ShuoZheLi/), -[sinjoywong](https://blog.csdn.net/SinjoyWong), -[sunqiuming526](https://github.com/sunqiuming526), -[Tianhao Zhou](https://github.com/tianhaoz95), -[timmmGZ](https://github.com/timmmGZ), -[tommytim0515](https://github.com/tommytim0515), -[ucsk](https://github.com/ucsk), -[wadegrc](https://github.com/wadegrc), -[walsvid](https://github.com/walsvid), -[warmingkkk](https://github.com/warmingkkk), -[Wonderxie](https://github.com/Wonderxie), -[wsyzxxxx](https://github.com/wsyzxxxx), -[xiaodp](https://github.com/xiaodp), -[youyun](https://github.com/youyun), -[yx-tan](https://github.com/yx-tan), -[Zero](https://github.com/Mr2er0), -[Ziming](https://github.com/ML-ZimingMeng/LeetCode-Python3) - -# Donate - -如果本仓库对你有帮助,可以请作者喝杯速溶咖啡 - - +labuladong's Algorithm Notes +This repository contains 60+ original articles, all based on LeetCode problems, covering every problem type and technique. The goal is to always teach you to generalize and make things easy to understand — not just dump code. A table of contents follows below. +Let me rant for a moment. Grinding LeetCode is about grinding problems, but more importantly, it's about building your thinking. The purpose of this repo is to pass on that algorithmic mindset. What's the point of just having a repo full of LeetCode solutions? No explanation of the approach, no thought framework — at most a time complexity note that anyone could figure out at a glance. +If you only want answers, that's easy — the comment sections are full of flashy one-liners in Python with thousands of likes. But ask yourself: are you doing algorithm problems to learn clever language tricks, or to build algorithmic thinking? Does your satisfaction come from copying someone's one-liner to tick off a problem, or from independently deriving a solution through logical reasoning and a framework you understand? +People online always criticize me for being too basic, or claim you can't learn algorithms through frameworks. My only response is: most of us grind algorithms to get jobs, not to win competitions. I've been through the grind myself. We want clarity and real takeaways, not mystification and vagueness. +If you don't try to make things clear and accessible, are you just going to start by hyping up Introduction to Algorithms (CLRS) and then scare everyone away with reverence? +The more you do anything, the more patterns you find. I've summarized various algorithm patterns and frameworks, and I believe they can help others avoid a lot of wasted effort. I'm a self-taught learner who spent a year grinding problems and writing summaries. I've put together my own algorithm cheat sheet — the table of contents is below. +Before You Start +1. Give this repo a star to satisfy my vanity — the content is absolutely worth one star. I'm still creating, so give me some motivation to keep writing. Thank you. +2. I recommend bookmarking my online website. Every article has a link to the corresponding LeetCode problem so you can read and practice at the same time — a total of 500 guided problems: +Latest 2024 address: https://labuladong.online/algo/ +GitHub Pages: https://labuladong.online/algo/ +Gitee Pages: https://labuladong.gitee.io/algo/ +Introduction to labuladong's Full Study Kit +I. Algorithm Visualization Panel +My algorithm website and all companion plugins include an algorithm visualization tool that visualizes data structures and recursion processes, greatly reducing the difficulty of understanding algorithms. Almost every problem's solution has a corresponding visualization panel — see the descriptions below for details. +II. Learning Website +The website is of course the core of my algorithm tutorial series. All my algorithm tutorials are published on labuladong.online. You'll likely spend a lot of learning time there — not just add it to your bookmarks~ +III. Chrome Extension +Main features: The Chrome extension lets you quickly view my "solutions" or "hints" on the Chinese LeetCode or English LeetCode, and adds cross-reference links between problems and algorithm techniques. It integrates with my website/newsletter/courses to give readers the smoothest possible problem-solving experience. See the table of contents below for the installation guide. +IV. VSCode Extension +Main features: Essentially the same as the Chrome extension. Recommended for readers who prefer solving problems in VSCode. See the table of contents below for the installation guide. +V. JetBrains Extension +Main features: Essentially the same as the Chrome extension. Recommended for readers who prefer JetBrains IDEs (PyCharm, IntelliJ, GoLand, etc.). See the table of contents below for the installation guide. +Wishing everyone a happy learning journey — swim freely in the sea of problems! +Table of Contents +Site Introduction +Learning Plans for Beginners and Fast-Trackers +Quick-Track Learning Plan +Complete Learning Plan +Key Points and Pitfalls in Algorithm Practice +How to Practice/Review the Exercise Chapters +Study Tool Usage Guide +AI Teaching Assistant for Q&A +Algorithm Visualization Panel Guide +Algorithm Games Overview +Companion Chrome Extension +Companion VSCode/Cursor Extension +Companion JetBrains Extension +Site Premium Membership +Beginner: Programming Language Basics & Practice +Chapter Introduction +C++ Language Basics +Java Language Basics +Golang Language Basics +Python Language Basics +JavaScript Language Basics +LeetCode Problem-Solving Essentials +Language-Specific LeetCode Practice +ACM Mode Code Templates +Foundation: Data Structures & Sorting In Depth +Chapter Introduction +Intro to Time & Space Complexity +Step-by-Step: Implement a Dynamic Array +Array (Sequential Storage) Fundamentals +Dynamic Array Code Implementation +Step-by-Step: Implement Singly/Doubly Linked Lists +Linked List (Linked Storage) Fundamentals +Linked List Code Implementation +[Game] Implement Snake +Array & Linked List Variations +Circular Array Technique & Implementation +Skip List Core Principles +Bitmap Principles & Implementation +Step-by-Step: Implement Queue/Stack +Queue/Stack Fundamentals +Queue/Stack via Linked List +Queue/Stack via Array +Deque (Double-Ended Queue) Principles & Implementation +Hash Table Principles & Implementation +Hash Table Core Principles +Hash Table via Chaining +Two Key Challenges in Linear Probing +Two Implementations of Linear Probing +Hash Set Principles & Implementation +Hash Table Variations +LinkedHashMap: Hash Table Enhanced with Linked List +ArrayHashMap: Hash Table Enhanced with Array +Bloom Filter Principles & Implementation +Binary Tree Structure & Traversal +Binary Tree Basics & Common Types +Recursive/Level-Order Traversal of Binary Trees +When to Use DFS vs BFS +Recursive/Level-Order Traversal of N-ary Trees +Binary Tree Variations +BST Applications & Visualization +Red-Black Tree Perfect Balance & Visualization +Trie / Prefix Tree Principles & Visualization +Binary Heap Core Principles & Visualization +Binary Heap / Priority Queue Implementation +Segment Tree Core Principles & Visualization +Data Compression & Huffman Trees +Still updating... +Graph Structure Basics & Algorithm Overview +Basic Terminology in Graph Theory +Generic Graph Code Implementation +DFS/BFS Traversal of Graphs +Eulerian Graphs & One-Stroke Drawing +Graph Shortest Path Algorithms Overview +Minimum Spanning Tree Algorithms Overview +Union-Find Fundamentals +Still updating... +Top 10 Sorting Algorithms: Principles & Visualization +Chapter Introduction +Key Metrics for Sorting Algorithms +The Problem with Selection Sort +Stability: Bubble Sort +Thinking in Reverse: Insertion Sort +Breaking O(N²): Shell Sort +Leveraging Pre-Order Position: Quick Sort +Leveraging Post-Order Position: Merge Sort +Applying Binary Heap: Heap Sort +A New Sorting Principle: Counting Sort +Best of All Worlds: Bucket Sort +Radix Sort +Still updating... +Chapter 0: Core Problem-Solving Frameworks Summary +Chapter Introduction +Framework Thinking for Learning Data Structures & Algorithms +Two-Pointer Technique: Solve 7 Linked List Problems +Two-Pointer Technique: Solve 7 Array Problems +Sliding Window Algorithm: Core Code Template +Binary Tree Algorithm Series: Core Outline +One Perspective + Two Thinking Modes for Recursion +Dynamic Programming: Problem-Solving Framework +Backtracking Algorithm: Problem-Solving Framework +BFS Algorithm: Problem-Solving Framework +Backtracking: Solve All Permutation/Combination/Subset Problems +Greedy Algorithm: Problem-Solving Framework +Divide & Conquer: Problem-Solving Framework +Practical Guide to Time & Space Complexity Analysis +Chapter 1: Classic Data Structure Algorithms +Step-by-Step Linked List Problems +Two-Pointer Technique: Solve 7 Linked List Problems +Classic Linked List Two-Pointer Exercises +All Ways to Reverse a Singly Linked List +How to Detect a Palindrome Linked List +Step-by-Step Array Problems +Two-Pointer Technique: Solve 7 Array Problems +[Game] Match-3 Game +Fancy 2D Array Traversal Techniques +Classic Array Two-Pointer Exercises +[Game] Game of Life +One Method to Solve All nSum Problems +Elegant Algorithm Technique: Prefix Sum Array +Classic Prefix Sum Exercises +Elegant Algorithm Technique: Difference Array +Sliding Window Algorithm: Core Code Template +Classic Sliding Window Exercises +Sliding Window Extension: Rabin-Karp String Matching +Binary Search Algorithm: Core Code Template +Binary Search: Left-Closed Right-Open Style +Mental Framework for Applying Binary Search in Practice +Classic Binary Search Exercises +Weighted Random Selection Algorithm +The Algorithm Behind Tian Ji's Horse Racing +Classic Queue/Stack Algorithms +Implement a Stack with a Queue and Vice Versa +Classic Stack Exercises +Parentheses Problem Collection +Classic Queue Exercises +Monotonic Stack Template: Solving 3 Example Problems +Monotonic Stack Variations & Classic Exercises +Monotonic Queue: Solving the Sliding Window Problem +Generic Monotonic Queue Implementation & Classic Exercises +Step-by-Step Binary Tree Problems +Binary Tree Series Core Outline +Binary Tree Mindset (Thinking Approach) +Binary Tree Mindset (Construction) +Binary Tree Mindset (Post-Order) +Binary Tree Mindset (Serialization) +BST Mindset (Properties) +BST Mindset (Basic Operations) +BST Mindset (Construction) +BST Mindset (Post-Order) +Binary Tree Exercise Collection +Chapter Introduction +Solving with "Traversal" Mindset I +Solving with "Traversal" Mindset II +Solving with "Traversal" Mindset III +Solving with "Problem Decomposition" Mindset I +Solving with "Problem Decomposition" Mindset II +Using Both Mindsets Together +Leveraging Post-Order Position I +Leveraging Post-Order Position II +Leveraging Post-Order Position III +Level-Order Traversal Problems I +Level-Order Traversal Problems II +Classic BST Problems I +Classic BST Problems II +Binary Tree Extensions +Extension: Lowest Common Ancestor Framework +Extension: Count Nodes in a Complete Binary Tree +Extension: Lazy Expansion of N-ary Trees +Extension: Merge Sort In Depth & Applications +Extension: Quick Sort In Depth & Applications +Extension: Iterative Binary Tree Traversal via Stack +Classic Data Structure Design +Algorithms Like LEGO: Build LRU Cache +Algorithms Like LEGO: Build LFU Cache +O(1) Delete/Find Any Element in an Array +More Hash Table Exercises +Classic Priority Queue Exercises +TreeMap/TreeSet Code Implementation +Basic Segment Tree Implementation +Optimization: Dynamic Segment Tree +Optimization: Lazy Update Segment Tree +Classic Segment Tree Exercises +Trie Code Implementation +Trie Algorithm Exercises +Design an Exam Room Seat Assignment Algorithm +More Classic Design Exercises +Implementing Huffman Encoding Compression +Consistent Hashing: Principles & Implementation +Extension: How to Implement a Calculator +Extension: Median Algorithm Using Two Binary Heaps +Extension: Array Deduplication (Hard Version) +Classic Graph Algorithms +Bipartite Graph Detection Algorithm +Hierholzer's Algorithm for Eulerian Paths +Classic Eulerian Path Exercises +Cycle Detection Algorithm +Topological Sort Algorithm +Union-Find Algorithm +Classic Union-Find Exercises +Dijkstra's Algorithm: Core Principles & Implementation +Dijkstra Extension: Shortest Path with Constraints +Classic Dijkstra Exercises +A* Algorithm: Core Principles & Implementation +Kruskal's MST Algorithm +Prim's MST Algorithm +Chapter 2: Classic Brute-Force Search Algorithms +DFS / Backtracking +Backtracking: Problem-Solving Framework +Backtracking in Practice: Sudoku & N-Queens +[Game] Implement a Sudoku Solver +Backtracking: Solve All Permutation/Combination/Subset Problems +Answering Common Questions About Backtracking/DFS +One Article to Solve All Island Problems +[Game] Minesweeper II +Ball-Box Model: Two Perspectives on Backtracking Enumeration +Backtracking in Practice: Generate Parentheses +Backtracking in Practice: Partition into K Equal Subsets +Classic Backtracking Exercises I +Classic Backtracking Exercises II +Classic Backtracking Exercises III +BFS Algorithm +BFS: Problem-Solving Framework +[Game] Solve a Maze +[Game] Huarong Road Puzzle +[Game] Link-Match Game +Classic BFS Exercises I +Classic BFS Exercises II +Chapter 3: Classic Dynamic Programming Algorithms +DP Fundamentals +Dynamic Programming: Problem-Solving Framework +DP Design: Longest Increasing Subsequence +How to Set Base Case and Memo Initial Values +Two Perspectives on DP Enumeration +Converting Between DP and Backtracking Thinking +Space Optimization for Dynamic Programming +Optimal Substructure and DP Array Traversal Direction +Subsequence Problems +Classic DP: Edit Distance +DP Design: Maximum Subarray +Classic DP: Longest Common Subsequence +DP Subsequence Problem Template +Knapsack Problems +Classic DP: 0-1 Knapsack +Classic DP: Subset Knapsack +Classic DP: Unbounded Knapsack +Knapsack Variant: Target Sum +DP for Games +DP: Minimum Path Sum +DP Helped Me Beat "Magic Tower" +DP Helped Me Beat "Fallout 4" +Travel Smart: Weighted Shortest Path +Multi-Source Shortest Path: Floyd's Algorithm +Classic DP: Regular Expression Matching +Classic DP: Egg Drop Problem +Classic DP: Burst Balloons +Classic DP: Game Theory Problems +One Method to Solve All House Robber Problems +One Method to Solve All Stock Trading Problems +DP Exercise Collection +House Robber Problem Pattern +Classic Knapsack Exercises +Classic DP Exercises I +Classic DP Exercises II +Greedy Problems +Greedy Algorithm: Problem-Solving Framework +Gas Station Greedy Algorithm +Greedy: Interval Scheduling Problem +Sweep Line Technique: Meeting Room Scheduling +Video Clipping: A Greedy Algorithm Emerges +Chapter 4: Other Common Algorithm Techniques +Math Tricks +Algorithm Problems Solvable in One Line of Code +Common Bit Manipulation Techniques +Essential Math Techniques +[Game] Minesweeper Map Generator +Random Algorithms in Games +Two Common Factorial Algorithm Problems +How to Find Prime Numbers Efficiently +Finding Both Missing and Duplicate Elements Simultaneously +Several Counter-Intuitive Probability Problems +Math Trick Related Exercises +Classic Interview Problems +How to Efficiently Solve Trapping Rain Water +One Article to Solve All Ugly Number Problems +One Method to Solve Three Interval Problems +Who Knew Card Games Could Inspire Algorithms +Pancake Sort Algorithm +String Multiplication +How to Detect a Perfect Rectangle +More Content +Computer Science Fundamentals +Frontend Development in the AI Era: A Beginner's Guide +Introduction to Modern Encryption +Deep Dive: Sessions and Cookies +Deep Dive: JSON Web Tokens (JWT) +Authentication vs. Authorization +Deep Dive: OAuth 2.0 Authorization Framework +OAuth 2.0 and OIDC Authentication +OAuth 2.0 and PKCE +Deep Dive: Single Sign-On (SSO) +Deep Dive: Digital Certificates and CA +Deep Dive: TLS Key Exchange +Deep Dive: mTLS Mutual Authentication +Introduction to Linux File Systems +Linux Processes, Threads, and File Descriptors Explained +Pitfalls with Linux Pipe Operators +Linux Shell Usage Tips +Storage Systems: LSM Tree Design Principles +Still updating... +Design Patterns +Singleton Pattern +Factory Method Pattern +Abstract Factory Pattern +Builder Pattern +Prototype Pattern +Adapter Pattern +Composite Pattern +Decorator Pattern +Bridge Pattern +Observer Pattern +Strategy Pattern +Still updating... +Thanks to the Following Contributors for Translations +Listed in alphabetical order by username: +ABCpril, andavid, bryceustc, build2645, CarrieOn, cooker, Dong Wang, ExcaliburEX, floatLig, ForeverSolar, Fulin Li, Funnyyanne, GYHHAHA, Hi_archer, Iruze, Jieyixia, Justin, Kevin, Lrc123, lriy, Lyjeeq, MasonShu, Master-cai, miaoxiaozui2017, natsunoyoru97, nettee, PaperJets, qy-yang, realism0331, SCUhzs, Seaworth, shazi4399, ShuozheLi, sinjoywong, sunqiuming526, Tianhao Zhou, timmmGZ, tommytim0515, ucsk, wadegrc, walsvid, warmingkkk, Wonderxie, wsyzxxxx, xiaodp, youyun, yx-tan, Zero, Ziming +Donate +If this repository has been helpful to you, you're welcome to buy the author a cup of instant coffee ☕ +�