diff --git a/README.md b/README.md index 0ab8612a0c..3fd3f6fcd6 100644 --- a/README.md +++ b/README.md @@ -210,12 +210,12 @@ Gitee Pages 地址:https://labuladong.gitee.io/algo/ * [如何用 BFS 算法秒杀各种智力题](https://labuladong.github.io/article/fname.html?fname=BFS解决滑动拼图) * [数学运算技巧](https://labuladong.github.io/algo/) + * [谈谈游戏中的随机算法](https://labuladong.github.io/article/fname.html?fname=随机算法) * [常用的位操作](https://labuladong.github.io/article/fname.html?fname=常用的位操作) * [讲两道常考的阶乘算法题](https://labuladong.github.io/article/fname.html?fname=阶乘题目) * [如何高效寻找素数](https://labuladong.github.io/article/fname.html?fname=打印素数) * [如何高效进行模幂运算](https://labuladong.github.io/article/fname.html?fname=superPower) * [如何同时寻找缺失和重复的元素](https://labuladong.github.io/article/fname.html?fname=缺失和重复的元素) - * [如何在无限序列中随机抽取元素](https://labuladong.github.io/article/fname.html?fname=水塘抽样) * [一行代码就能解决的算法题](https://labuladong.github.io/article/fname.html?fname=一行代码解决的智力题) * [几个反直觉的概率问题](https://labuladong.github.io/article/fname.html?fname=几个反直觉的概率问题) @@ -240,6 +240,8 @@ Gitee Pages 地址:https://labuladong.gitee.io/algo/ * [Linux shell 的实用小技巧](https://labuladong.github.io/article/fname.html?fname=linuxshell技巧) * [Linux 管道符原理大揭秘](https://labuladong.github.io/article/fname.html?fname=linux技巧3) * [一文看懂 session 和 cookie](https://labuladong.github.io/article/fname.html?fname=session和cookie) + * [消息队列架构设计演进](https://labuladong.github.io/article/fname.html?fname=消息队列) + * [存储系统设计之 LSM 树原理](https://labuladong.github.io/article/fname.html?fname=LSM树) * [加密算法的前身今世](https://labuladong.github.io/article/fname.html?fname=密码技术) * [我用四个命令概括了 Git 的所有套路](https://labuladong.github.io/article/fname.html?fname=git常用命令) * [Git/SQL/正则表达式的在线练习平台](https://labuladong.github.io/article/fname.html?fname=在线练习平台) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/LCS.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/LCS.md" index db7a3cc79a..5666c7aa21 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/LCS.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/LCS.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円KMP345円255円227円347円254円246円345円214円271円351円205円215円347円256円227円346円263円225円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円KMP345円255円227円347円254円246円345円214円271円351円205円215円347円256円227円346円263円225円.md" index b5856dd925..35c321adea 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円KMP345円255円227円347円254円246円345円214円271円351円205円215円347円256円227円346円263円225円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円KMP345円255円227円347円254円246円345円214円271円351円205円215円347円256円227円346円263円225円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -438,7 +438,7 @@ KMP 算法也就是动态规划那点事,我们的公众号文章目录有一 **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円215円232円345円274円210円351円227円256円351円242円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円215円232円345円274円210円351円227円256円351円242円230円.md" index 53845c7681..986af5ef9d 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円215円232円345円274円210円351円227円256円351円242円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円215円232円345円274円210円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -240,7 +240,7 @@ int stoneGame(int[] piles) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円233円233円351円224円256円351円224円256円347円233円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円233円233円351円224円256円351円224円256円347円233円230円.md" index 96296df8a3..f4fb2eda63 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円233円233円351円224円256円351円224円256円347円233円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円345円233円233円351円224円256円351円224円256円347円233円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -230,7 +230,7 @@ def dp(n, a_num, copy): **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円346円255円243円345円210円231円350円241円250円350円276円276円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円346円255円243円345円210円231円350円241円250円350円276円276円.md" index 3d06fde8b2..31701f2bb8 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円346円255円243円345円210円231円350円241円250円350円276円276円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円344円271円213円346円255円243円345円210円231円350円241円250円350円276円276円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円256円276円350円256円241円357円274円232円346円234円200円351円225円277円351円200円222円345円242円236円345円255円220円345円272円217円345円210円227円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円256円276円350円256円241円357円274円232円346円234円200円351円225円277円351円200円222円345円242円236円345円255円220円345円272円217円345円210円227円.md" index d13b006483..ad741d36a2 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円256円276円350円256円241円357円274円232円346円234円200円351円225円277円351円200円222円345円242円236円345円255円220円345円272円217円345円210円227円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円256円276円350円256円241円357円274円232円346円234円200円351円225円277円351円200円222円345円242円236円345円255円220円345円272円217円345円210円227円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -327,7 +327,7 @@ int lengthOfLIS(int[] nums) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円257円246円350円247円243円350円277円233円351円230円266円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円257円246円350円247円243円350円277円233円351円230円266円.md" index acc1ff58e7..821b3ae02d 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円257円246円350円247円243円350円277円233円351円230円266円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円212円250円346円200円201円350円247円204円345円210円222円350円257円246円350円247円243円350円277円233円351円230円266円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -496,7 +496,7 @@ int coinChange(int[] coins, int amount) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円215円225円350円257円215円346円213円274円346円216円245円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円215円225円350円257円215円346円213円274円346円216円245円.md" index a47d1a794f..39b34032ba 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円215円225円350円257円215円346円213円274円346円216円245円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円215円225円350円257円215円346円213円274円346円216円245円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -445,6 +445,6 @@ List dp(String s, int i) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円233円242円347円201円255円350円202円241円347円245円250円351円227円256円351円242円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円233円242円347円201円255円350円202円241円347円245円250円351円227円256円351円242円230円.md" index 163d977cbf..d607c68ca8 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円233円242円347円201円255円350円202円241円347円245円250円351円227円256円351円242円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円233円242円347円201円255円350円202円241円347円245円250円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -709,6 +709,6 @@ int maxProfit_k_inf(int[] prices, int cooldown, int fee) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円255円220円345円272円217円345円210円227円351円227円256円351円242円230円346円250円241円346円235円277円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円255円220円345円272円217円345円210円227円351円227円256円351円242円230円346円250円241円346円235円277円.md" index a6241a76c8..c20300a335 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円255円220円345円272円217円345円210円227円351円227円256円351円242円230円346円250円241円346円235円277円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/345円255円220円345円272円217円345円210円227円351円227円256円351円242円230円346円250円241円346円235円277円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円212円242円346円210円277円345円255円220円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円212円242円346円210円277円345円255円220円.md" index 9c394b5352..5a00974f2c 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円212円242円346円210円277円345円255円220円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円212円242円346円210円277円345円255円220円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円234円200円344円274円230円345円255円220円347円273円223円346円236円204円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円234円200円344円274円230円345円255円220円347円273円223円346円236円204円.md" index b1b789de62..ec0990825d 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円234円200円344円274円230円345円255円220円347円273円223円346円236円204円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/346円234円200円344円274円230円345円255円220円347円273円223円346円236円204円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -180,13 +180,12 @@ bool dp(string& s, int i, string& p, int j) { dp(s, i, p, j + 2); // #1 dp(s, i + 1, p, j); // #2 dp(s, i + 1, p, j + 1); // #3 - dp(s, i, p, j + 2); // #4 } ``` 和上一题一样,这个解法的「状态」也是 `(i, j)` 的值,那么我继续问你问题:如果我想从状态 `(i, j)` 转移到 `(i+2, j+2)`,有几种路径? -显然,至少有两条路径:`(i, j) -> #1 -> #4` 和 `(i, j) -> #3 -> #3`。 +显然,至少有两条路径:`(i, j) -> #1 -> #2 -> #2` 和 `(i, j) -> #3 -> #3`,这就说明这个解法存在巨量重叠子问题。 所以,不用画图就知道这个解法也存在重叠子问题,需要用备忘录技巧去优化。 @@ -377,7 +376,7 @@ for (int i = 1; i < m; i++) **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円212円266円346円200円201円345円216円213円347円274円251円346円212円200円345円267円247円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円212円266円346円200円201円345円216円213円347円274円251円346円212円200円345円267円247円.md" index 7156753663..57ffe82eed 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円212円266円346円200円201円345円216円213円347円274円251円346円212円200円345円267円247円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円212円266円346円200円201円345円216円213円347円274円251円346円212円200円345円267円247円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -245,6 +245,6 @@ int longestPalindromeSubseq(string s) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円274円226円350円276円221円350円267円235円347円246円273円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円274円226円350円276円221円350円267円235円347円246円273円.md" index 380abfd742..40837b81f8 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円274円226円350円276円221円350円267円235円347円246円273円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/347円274円226円350円276円221円350円267円235円347円246円273円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -356,7 +356,7 @@ class Node { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円203円214円345円214円205円351円227円256円351円242円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円203円214円345円214円205円351円227円256円351円242円230円.md" index df66536d53..808d3db392 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円203円214円345円214円205円351円227円256円351円242円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円203円214円345円214円205円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -124,6 +124,7 @@ return dp[N][W] ```java int knapsack(int W, int N, int[] wt, int[] val) { + assert N == wt.length; // base case 已初始化 int[][] dp = new int[N + 1][W + 1]; for (int i = 1; i <= N; i++) { @@ -145,6 +146,8 @@ int knapsack(int W, int N, int[] wt, int[] val) { } ``` +> PS:其实函数签名中的物品数量 `N` 就是 `wt` 数组的长度,所以实际上这个参数 `N` 是多此一举的。但为了体现原汁原味的 0-1 背包问题,我就带上这个参数 `N` 了,你自己写的话可以省略。 + 至此,背包问题就解决了,相比而言,我觉得这是比较简单的动态规划问题,因为状态转移的推导比较自然,基本上你明确了 `dp` 数组的定义,就可以理所当然地确定状态转移了。 接下来可阅读: @@ -171,6 +174,6 @@ int knapsack(int W, int N, int[] wt, int[] val) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円264円252円345円277円203円347円256円227円346円263円225円344円271円213円345円214円272円351円227円264円350円260円203円345円272円246円351円227円256円351円242円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円264円252円345円277円203円347円256円227円346円263円225円344円271円213円345円214円272円351円227円264円350円260円203円345円272円246円351円227円256円351円242円230円.md" index 7a597abb8b..403230912d 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円264円252円345円277円203円347円256円227円346円263円225円344円271円213円345円214円272円351円227円264円350円260円203円345円272円246円351円227円256円351円242円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/350円264円252円345円277円203円347円256円227円346円263円225円344円271円213円345円214円272円351円227円264円350円260円203円345円272円246円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -184,7 +184,7 @@ int findMinArrowShots(int[][] intvs) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円253円230円346円245円274円346円211円224円351円270円241円350円233円213円351円227円256円351円242円230円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円253円230円346円245円274円346円211円224円351円270円241円350円233円213円351円227円256円351円242円230円.md" index da6175a2d7..0dc912756a 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円253円230円346円245円274円346円211円224円351円270円241円350円233円213円351円227円256円351円242円230円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円253円230円346円245円274円346円211円224円351円270円241円350円233円213円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円255円224円345円241円224円.md" "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円255円224円345円241円224円.md" index 2bb05dc86e..0f0bcde9d4 100644 --- "a/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円255円224円345円241円224円.md" +++ "b/345円212円250円346円200円201円350円247円204円345円210円222円347円263円273円345円210円227円/351円255円224円345円241円224円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -33,7 +33,7 @@ 输入一个存储着整数的二维数组 `grid`,如果 `grid[i][j]> 0`,说明这个格子装着血瓶,经过它可以增加对应的生命值;如果 `grid[i][j] == 0`,则这是一个空格子,经过它不会发生任何事情;如果 `grid[i][j] < 0`,说明这个格子有怪物,经过它会损失对应的生命值。 -现在你是一名骑士,将会出现在最上角,公主被困在最右下角,你只能向右和向下移动,请问你初始至少需要多少生命值才能成功救出公主? +现在你是一名骑士,将会出现在最左上角,公主被困在最右下角,你只能向右和向下移动,请问你初始至少需要多少生命值才能成功救出公主? **换句话说,就是问你至少需要多少初始生命值,能够让骑士从最左上角移动到最右下角,且任何时候生命值都要大于 0**。 @@ -249,6 +249,6 @@ int dp(int[][] grid, int i, int j) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/linuxshell.md" "b/346円212円200円346円234円257円/linuxshell.md" index beb3c53fbf..f3d10399d9 100644 --- "a/346円212円200円346円234円257円/linuxshell.md" +++ "b/346円212円200円346円234円257円/linuxshell.md" @@ -1,9 +1,5 @@ # 关于 Linux shell 你必须知道的技巧 - - - -

GitHub @@ -13,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -150,6 +146,20 @@ $ where connect.sh $ sudo /home/fdl/bin/connect.sh ``` + + +


+
+引用本文的文章 + + - [Linux 管道符原理大揭秘](https://labuladong.github.io/article/fname.html?fname=linux技巧3) + +

+ + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円212円200円346円234円257円/linux350円277円233円347円250円213円.md" "b/346円212円200円346円234円257円/linux350円277円233円347円250円213円.md" index ac4b45b914..7c5f4380b9 100644 --- "a/346円212円200円346円234円257円/linux350円277円233円347円250円213円.md" +++ "b/346円212円200円346円234円257円/linux350円277円233円347円250円213円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -148,7 +148,7 @@ $ cmd1 | cmd2 | cmd3 **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/redis345円205円245円344円276円265円.md" "b/346円212円200円346円234円257円/redis345円205円245円344円276円265円.md" index 1561cf8363..a7680d4c7a 100644 --- "a/346円212円200円346円234円257円/redis345円205円245円344円276円265円.md" +++ "b/346円212円200円346円234円257円/redis345円205円245円344円276円265円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -101,7 +101,7 @@ Redis 监听的默认端口是 6379,我们设置它接收网卡 127.0.0.1 的 **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/session345円222円214円cookie.md" "b/346円212円200円346円234円257円/session345円222円214円cookie.md" index 7216b772ec..47a6944d56 100644 --- "a/346円212円200円346円234円257円/session345円222円214円cookie.md" +++ "b/346円212円200円346円234円257円/session345円222円214円cookie.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -148,7 +148,7 @@ https://github.com/astaxie/build-web-application-with-golang **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/345円210円267円351円242円230円346円212円200円345円267円247円.md" "b/346円212円200円346円234円257円/345円210円267円351円242円230円346円212円200円345円267円247円.md" index 9ad6d47fbe..f1a41e0cc5 100644 --- "a/346円212円200円346円234円257円/345円210円267円351円242円230円346円212円200円345円267円247円.md" +++ "b/346円212円200円346円234円257円/345円210円267円351円242円230円346円212円200円345円267円247円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -277,6 +277,6 @@ int dp(string& ring, int i, string& key, int j) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/345円234円250円347円272円277円347円273円203円344円271円240円345円271円263円345円217円260円.md" "b/346円212円200円346円234円257円/345円234円250円347円272円277円347円273円203円344円271円240円345円271円263円345円217円260円.md" index 3216bb6a99..dd11c3b6b9 100644 --- "a/346円212円200円346円234円257円/345円234円250円347円272円277円347円273円203円344円271円240円345円271円263円345円217円260円.md" +++ "b/346円212円200円346円234円257円/345円234円250円347円272円277円347円273円203円344円271円240円345円271円263円345円217円260円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -123,7 +123,7 @@ https://sqlzoo.net/ **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円212円200円346円234円257円/345円257円206円347円240円201円346円212円200円346円234円257円.md" "b/346円212円200円346円234円257円/345円257円206円347円240円201円346円212円200円346円234円257円.md" index c7f08f2272..d5eb011898 100644 --- "a/346円212円200円346円234円257円/345円257円206円347円240円201円346円212円200円346円234円257円.md" +++ "b/346円212円200円346円234円257円/345円257円206円347円240円201円346円212円200円346円234円257円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -197,7 +197,7 @@ HTTPS 协议中的 SSL/TLS 安全层会组合使用以上几种加密方式,** **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST1.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST1.md" index 4e15c9fd8c..f39167651d 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST1.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST1.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -24,6 +24,8 @@ **-----------** +> 本文有视频版:[动手实现 TreeMap](https://appktavsiei5995.pc.xiaoe-tech.com/detail/p_62655516e4b0cedf38a93758/6) + PS:[刷题插件](https://mp.weixin.qq.com/s/OE1zPVPj0V2o82N4HtLQbw) 集成了手把手刷二叉树功能,按照公式和套路讲解了 150 道二叉树题目,可手把手带你刷完二叉树分类的题目,迅速掌握递归思维。 前文手把手带你刷二叉树已经写了 [第一期](https://labuladong.github.io/article/fname.html?fname=二叉树系列1),[第二期](https://labuladong.github.io/article/fname.html?fname=二叉树系列2) 和 [第三期](https://labuladong.github.io/article/fname.html?fname=二叉树系列3),今天写一篇二叉搜索树(Binary Search Tree,后文简写 BST)相关的文章,手把手带你刷 BST。 @@ -215,7 +217,7 @@ void traverse(TreeNode root) { 简单总结下吧,BST 相关的问题,要么利用 BST 左小右大的特性提升算法效率,要么利用中序遍历的特性满足题目的要求,也就这么些事儿吧。 -最后调查下,经过这几篇二叉树相关的系列文章,大家刷题有没有点感觉了?可以留言和我交流。本文对你有帮助的话,请三连~ +当然,BST 还可以玩出更多花样,提供更丰富的 API,更多内容参见我的数据结构课程中的 [动手实现 TreeMap](https://appktavsiei5995.pc.xiaoe-tech.com/detail/p_62655516e4b0cedf38a93758/6) 章节。 @@ -248,6 +250,6 @@ void traverse(TreeNode root) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST2.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST2.md" index bb1246cba3..887487b7fa 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST2.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/BST2.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -311,6 +311,6 @@ void BST(TreeNode root, int target) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/dijkstra347円256円227円346円263円225円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/dijkstra347円256円227円346円263円225円.md" index 76e0a6e155..418b4cb444 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/dijkstra347円256円227円346円263円225円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/dijkstra347円256円227円346円263円225円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -864,6 +864,6 @@ double dijkstra(int start, int end, List[] graph) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円345円240円206円350円257円246円350円247円243円345円256円236円347円216円260円344円274円230円345円205円210円347円272円247円351円230円237円345円210円227円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円345円240円206円350円257円246円350円247円243円345円256円236円347円216円260円344円274円230円345円205円210円347円272円247円351円230円237円345円210円227円.md" index 33982ee228..bc673a90c4 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円345円240円206円350円257円246円350円247円243円345円256円236円347円216円260円344円274円230円345円205円210円347円272円247円351円230円237円345円210円227円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円345円240円206円350円257円246円350円247円243円345円256円236円347円216円260円344円274円230円345円205円210円347円272円247円351円230円237円345円210円227円.md" @@ -1,13 +1,5 @@ # 二叉堆详解实现优先级队列 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -234,6 +226,45 @@ public Key delMax() { 最后,更多二叉堆/优先级队列相关的题目练习见 [二叉堆(优先级队列)的经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_633faa64e4b0eca59c3a1aa3/1)。 + + +


+
+引用本文的文章 + + - [Dijkstra 算法模板及应用](https://labuladong.github.io/article/fname.html?fname=dijkstra算法) + - [双指针技巧秒杀七道链表题目](https://labuladong.github.io/article/fname.html?fname=链表技巧) + - [如何调度考生的座位](https://labuladong.github.io/article/fname.html?fname=座位调度) + - [快速排序详解及应用](https://labuladong.github.io/article/fname.html?fname=快速排序) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1104. Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/?show=1) | [1104. 二叉树寻路](https://leetcode.cn/problems/path-in-zigzag-labelled-binary-tree/?show=1) | +| [1845. Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager/?show=1) | [1845. 座位预约管理系统](https://leetcode.cn/problems/seat-reservation-manager/?show=1) | +| [23. Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/?show=1) | [23. 合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/?show=1) | +| [347. Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/?show=1) | [347. 前 K 个高频元素](https://leetcode.cn/problems/top-k-frequent-elements/?show=1) | +| [451. Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency/?show=1) | [451. 根据字符出现频率排序](https://leetcode.cn/problems/sort-characters-by-frequency/?show=1) | +| [662. Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree/?show=1) | [662. 二叉树最大宽度](https://leetcode.cn/problems/maximum-width-of-binary-tree/?show=1) | +| [692. Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words/?show=1) | [692. 前K个高频单词](https://leetcode.cn/problems/top-k-frequent-words/?show=1) | +| [703. Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream/?show=1) | [703. 数据流中的第 K 大元素](https://leetcode.cn/problems/kth-largest-element-in-a-stream/?show=1) | +| - | [剑指 Offer II 059. 数据流的第 K 大数值](https://leetcode.cn/problems/jBjn9C/?show=1) | +| - | [剑指 Offer II 078. 合并排序链表](https://leetcode.cn/problems/vvXgSW/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円346円200円273円347円273円223円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円346円200円273円347円273円223円.md" index c1dc73b35b..7e84245be7 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円346円200円273円347円273円223円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円346円200円273円347円273円223円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -791,6 +791,6 @@ void traverse(List
curLevelNodes) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2271円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2271円.md" index a2f13b169f..81bdea745c 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2271円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2271円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -388,7 +388,7 @@ void flatten(TreeNode root) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2272円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2272円.md" index 87f222cc9f..4a0d3db7f6 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2272円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/344円272円214円345円217円211円346円240円221円347円263円273円345円210円2272円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -175,7 +175,7 @@ void traverse(TreeNode root) { 找到根节点是很简单的,前序遍历的第一个值 `preorder[0]` 就是根节点的值。 -关键在于如何通过根节点的值,将 `preorder` 和 `postorder` 数组划分成两半,构造根节点的左右子树? +关键在于如何通过根节点的值,将 `preorder` 和 `inorder` 数组划分成两半,构造根节点的左右子树? 换句话说,对于以下代码中的 `?` 部分应该填入什么: @@ -583,6 +583,6 @@ int leftRootVal = preorder[preStart + 1]; **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円346円240円210円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円346円240円210円.md" index 3b06770985..7282ead98a 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円346円240円210円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円346円240円210円.md" @@ -1,13 +1,5 @@ # 特殊数据结构:单调栈 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -205,6 +197,43 @@ int[] nextGreaterElements(int[] nums) { 我会在 [单调栈的几种变体](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_628dc1ace4b09dda126cf793/1) 对比单调栈的几种其他形式,并在 [单调栈的运用](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_628dc2d7e4b0cedf38b67734/1) 中给出单调栈的经典例题。更多数据结构设计类题目参见 [数据结构设计经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_6312b9e5e4b0eca59c2b7e93/1)。 + + +


+
+引用本文的文章 + + - [一个方法团灭 LeetCode 打家劫舍问题](https://labuladong.github.io/article/fname.html?fname=抢房子) + - [一道数组去重的算法题把我整不会了](https://labuladong.github.io/article/fname.html?fname=单调栈去重) + - [单调栈代码模板的几种变体](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_628dc1ace4b09dda126cf793/1) + - [单调队列的通用实现及经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a692efe4b01a48520b9b9b/1) + - [单调队列结构解决滑动窗口问题](https://labuladong.github.io/article/fname.html?fname=单调队列) + - [数据结构设计:最大栈](https://labuladong.github.io/article/fname.html?fname=最大栈) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1019. Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list/?show=1) | [1019. 链表中的下一个更大节点](https://leetcode.cn/problems/next-greater-node-in-linked-list/?show=1) | +| [1944. Number of Visible People in a Queue](https://leetcode.com/problems/number-of-visible-people-in-a-queue/?show=1) | [1944. 队列中可以看到的人数](https://leetcode.cn/problems/number-of-visible-people-in-a-queue/?show=1) | +| [402. Remove K Digits](https://leetcode.com/problems/remove-k-digits/?show=1) | [402. 移掉 K 位数字](https://leetcode.cn/problems/remove-k-digits/?show=1) | +| [42. Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/?show=1) | [42. 接雨水](https://leetcode.cn/problems/trapping-rain-water/?show=1) | +| [901. Online Stock Span](https://leetcode.com/problems/online-stock-span/?show=1) | [901. 股票价格跨度](https://leetcode.cn/problems/online-stock-span/?show=1) | +| [918. Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray/?show=1) | [918. 环形子数组的最大和](https://leetcode.cn/problems/maximum-sum-circular-subarray/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円351円230円237円345円210円227円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円351円230円237円345円210円227円.md" index b8c239a011..bcbcc25c8d 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円351円230円237円345円210円227円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円215円225円350円260円203円351円230円237円345円210円227円.md" @@ -1,13 +1,5 @@ # 特殊数据结构:单调队列 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -272,6 +264,38 @@ class MonotonicQueue> { 我将在 [单调队列通用实现及应用](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a692efe4b01a48520b9b9b/1) 中给出单调队列的通用实现和经典习题。更多数据结构设计类题目参见 [数据结构设计经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_6312b9e5e4b0eca59c2b7e93/1)。 + + +


+
+引用本文的文章 + + - [数据结构设计:最大栈](https://labuladong.github.io/article/fname.html?fname=最大栈) + - [算法时空复杂度分析实用指南](https://labuladong.github.io/article/fname.html?fname=时间复杂度) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1425. Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum/?show=1) | [1425. 带限制的子序列和](https://leetcode.cn/problems/constrained-subsequence-sum/?show=1) | +| [1696. Jump Game VI](https://leetcode.com/problems/jump-game-vi/?show=1) | [1696. 跳跃游戏 VI](https://leetcode.cn/problems/jump-game-vi/?show=1) | +| [862. Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/?show=1) | [862. 和至少为 K 的最短子数组](https://leetcode.cn/problems/shortest-subarray-with-sum-at-least-k/?show=1) | +| [918. Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray/?show=1) | [918. 环形子数组的最大和](https://leetcode.cn/problems/maximum-sum-circular-subarray/?show=1) | +| - | [剑指 Offer 59 - I. 滑动窗口的最大值](https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円233円276円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円233円276円.md" index d31d28ec99..b776da2900 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円233円276円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円233円276円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -354,6 +354,6 @@ void traverse(int[][] graph, int s, LinkedList path) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円256円236円347円216円260円350円256円241円347円256円227円345円231円250円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円256円236円347円216円260円350円256円241円347円256円227円345円231円250円.md" index f81830bcc4..106f8e5ad3 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円256円236円347円216円260円350円256円241円347円256円227円345円231円250円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/345円256円236円347円216円260円350円256円241円347円256円227円345円231円250円.md" @@ -1,11 +1,5 @@ # 拆解复杂问题:实现计算器 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -311,6 +305,20 @@ def calculate(s: str) -> int: **退而求其次是一种很聪明策略**。你想想啊,假设这是一道考试题,你不会实现这个计算器,但是你写了字符串转整数的算法并指出了容易溢出的陷阱,那起码可以得 20 分吧;如果你能够处理加减法,那可以得 40 分吧;如果你能处理加减乘除四则运算,那起码够 70 分了;再加上处理空格字符,80 有了吧。我就是不会处理括号,那就算了,80 已经很 OK 了好不好。 + + +


+
+引用本文的文章 + + - [算法笔试「骗分」套路](https://labuladong.github.io/article/fname.html?fname=刷题技巧) + +

+ + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/346円213円223円346円211円221円346円216円222円345円272円217円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/346円213円223円346円211円221円346円216円222円345円272円217円.md" index e8957b135f..b8e12b01ed 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/346円213円223円346円211円221円346円216円222円345円272円217円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/346円213円223円346円211円221円346円216円222円345円272円217円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -602,6 +602,6 @@ List[] buildGraph(int n, int[][] edges) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/350円256円276円350円256円241円Twitter.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/350円256円276円350円256円241円Twitter.md" index f2b409cec0..60294dc2a5 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/350円256円276円350円256円241円Twitter.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/350円256円276円350円256円241円Twitter.md" @@ -1,11 +1,5 @@ # 设计Twitter - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -296,6 +290,20 @@ public List getNewsFeed(int userId) { 本文就到这里,更多数据结构设计相关的题目参见 [数据结构设计经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_6312b9e5e4b0eca59c2b7e93/1)。 + + +


+
+引用本文的文章 + + - [数据结构设计:最大栈](https://labuladong.github.io/article/fname.html?fname=最大栈) + +

+ + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円200円222円345円275円222円345円217円215円350円275円254円351円223円276円350円241円250円347円232円204円344円270円200円351円203円250円345円210円206円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円200円222円345円275円222円345円217円215円350円275円254円351円223円276円350円241円250円347円232円204円344円270円200円351円203円250円345円210円206円.md" index 7f228726e2..fe37a3ff51 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円200円222円345円275円222円345円217円215円350円275円254円351円223円276円350円241円250円347円232円204円344円270円200円351円203円250円345円210円206円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円200円222円345円275円222円345円217円215円350円275円254円351円223円276円350円241円250円347円232円204円344円270円200円351円203円250円345円210円206円.md" @@ -1,13 +1,5 @@ # 递归反转链表的一部分 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -229,6 +221,35 @@ ListNode reverseBetween(ListNode head, int m, int n) { 最后,我在数据结构精品课中讲解了 [单链表的递归实现](https://aep.h5.xeknow.com/s/1RQzXc),应该能够让你进一步加深对递归的理解。 + + +


+
+引用本文的文章 + + - [如何判断回文链表](https://labuladong.github.io/article/fname.html?fname=判断回文链表) + - [烧饼排序算法](https://labuladong.github.io/article/fname.html?fname=烧饼排序) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| - | [剑指 Offer 24. 反转链表](https://leetcode.cn/problems/fan-zhuan-lian-biao-lcof/?show=1) | +| - | [剑指 Offer II 024. 反转链表](https://leetcode.cn/problems/UHnkqh/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円346円240円210円345円256円236円347円216円260円351円230円237円345円210円227円.md" "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円346円240円210円345円256円236円347円216円260円351円230円237円345円210円227円.md" index 7fd57ea00c..645f680010 100644 --- "a/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円346円240円210円345円256円236円347円216円260円351円230円237円345円210円227円.md" +++ "b/346円225円260円346円215円256円347円273円223円346円236円204円347円263円273円345円210円227円/351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円346円240円210円345円256円236円347円216円260円351円230円237円345円210円227円.md" @@ -1,9 +1,5 @@ # 队列实现栈|栈实现队列 - - - -

GitHub @@ -13,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -227,6 +223,23 @@ public boolean empty() { 希望本文对你有帮助。 + + + +


+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| - | [剑指 Offer 09. 用两个栈实现队列](https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS346円241円206円346円236円266円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS346円241円206円346円236円266円.md" index 01541bf1d9..9109723e3d 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS346円241円206円346円236円266円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS346円241円206円346円236円266円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -424,6 +424,6 @@ while (!q1.isEmpty() && !q2.isEmpty()) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS350円247円243円345円206円263円346円273円221円345円212円250円346円213円274円345円233円276円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS350円247円243円345円206円263円346円273円221円345円212円250円346円213円274円345円233円276円.md" index 40e7d6ba32..17c4817089 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS350円247円243円345円206円263円346円273円221円345円212円250円346円213円274円345円233円276円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/BFS350円247円243円345円206円263円346円273円221円345円212円250円346円213円274円345円233円276円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -183,6 +183,6 @@ private String swap(char[] chars, int i, int j) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/UnionFind347円256円227円346円263円225円350円257円246円350円247円243円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/UnionFind347円256円227円346円263円225円350円257円246円350円247円243円.md" index 6f11fed5fd..53e6bf143a 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/UnionFind347円256円227円346円263円225円350円257円246円350円247円243円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/UnionFind347円256円227円346円263円225円350円257円246円350円247円243円.md" @@ -1,11 +1,5 @@ # Union-Find 算法详解 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -529,6 +523,41 @@ class UF { 最后,Union-Find 算法也会在一些其他经典图论算法中用到,比如判断「图」和「树」,以及最小生成树的计算,详情见 [Kruskal 最小生成树算法](https://labuladong.github.io/article/fname.html?fname=kruskal)。 + + +


+
+引用本文的文章 + + - [Dijkstra 算法模板及应用](https://labuladong.github.io/article/fname.html?fname=dijkstra算法) + - [Kruskal 最小生成树算法](https://labuladong.github.io/article/fname.html?fname=kruskal) + - [Prim 最小生成树算法](https://labuladong.github.io/article/fname.html?fname=prim算法) + - [一文秒杀所有岛屿题目](https://labuladong.github.io/article/fname.html?fname=岛屿题目) + - [二分图判定算法](https://labuladong.github.io/article/fname.html?fname=二分图) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1361. Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes/?show=1) | [1361. 验证二叉树](https://leetcode.cn/problems/validate-binary-tree-nodes/?show=1) | +| [200. Number of Islands](https://leetcode.com/problems/number-of-islands/?show=1) | [200. 岛屿数量](https://leetcode.cn/problems/number-of-islands/?show=1) | +| [261. Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree/?show=1)🔒 | [261. 以图判树](https://leetcode.cn/problems/graph-valid-tree/?show=1)🔒 | +| [765. Couples Holding Hands](https://leetcode.com/problems/couples-holding-hands/?show=1) | [765. 情侣牵手](https://leetcode.cn/problems/couples-holding-hands/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円350円257円246円350円247円243円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円350円257円246円350円247円243円.md" index f3e5d4103d..706b417856 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円350円257円246円350円247円243円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円350円257円246円350円247円243円.md" @@ -1,13 +1,5 @@ # 二分查找算法详解 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -507,6 +499,60 @@ int right_bound(int[] nums, int target) { 理解本文能保证你写出正确的二分查找的代码,但实际题目中不会直接让你写二分代码,我会在 [二分查找的变体](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a07736e4b01a485209b0b4/1) 和 [二分查找的运用](https://labuladong.github.io/article/fname.html?fname=二分运用) 中进一步讲解如何把二分思维运用到更多算法题中。 + + +


+
+引用本文的文章 + + - [base case 和备忘录的初始值怎么定?](https://labuladong.github.io/article/fname.html?fname=备忘录等基础) + - [丑数系列算法详解](https://labuladong.github.io/article/fname.html?fname=丑数) + - [二分搜索怎么用?我又总结了套路](https://labuladong.github.io/article/fname.html?fname=二分运用) + - [二分搜索怎么用?我和快手面试官进行了深度探讨](https://labuladong.github.io/article/fname.html?fname=二分分割子数组) + - [二分搜索算法经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a07736e4b01a485209b0b4/1) + - [二分查找高效判定子序列](https://labuladong.github.io/article/fname.html?fname=二分查找判定子序列) + - [动态规划设计:最长递增子序列](https://labuladong.github.io/article/fname.html?fname=动态规划设计:最长递增子序列) + - [双指针技巧秒杀七道数组题目](https://labuladong.github.io/article/fname.html?fname=双指针技巧) + - [存储系统设计之 LSM 树原理](https://labuladong.github.io/article/fname.html?fname=LSM树) + - [带权重的随机选择算法](https://labuladong.github.io/article/fname.html?fname=随机权重) + - [快速排序详解及应用](https://labuladong.github.io/article/fname.html?fname=快速排序) + - [我写了首诗,把滑动窗口算法变成了默写题](https://labuladong.github.io/article/fname.html?fname=滑动窗口技巧进阶) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + - [讲两道常考的阶乘算法题](https://labuladong.github.io/article/fname.html?fname=阶乘题目) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1201. Ugly Number III](https://leetcode.com/problems/ugly-number-iii/?show=1) | [1201. 丑数 III](https://leetcode.cn/problems/ugly-number-iii/?show=1) | +| [162. Find Peak Element](https://leetcode.com/problems/find-peak-element/?show=1) | [162. 寻找峰值](https://leetcode.cn/problems/find-peak-element/?show=1) | +| [240. Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii/?show=1) | [240. 搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/?show=1) | +| [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/?show=1) | [33. 搜索旋转排序数组](https://leetcode.cn/problems/search-in-rotated-sorted-array/?show=1) | +| [35. Search Insert Position](https://leetcode.com/problems/search-insert-position/?show=1) | [35. 搜索插入位置](https://leetcode.cn/problems/search-insert-position/?show=1) | +| [658. Find K Closest Elements](https://leetcode.com/problems/find-k-closest-elements/?show=1) | [658. 找到 K 个最接近的元素](https://leetcode.cn/problems/find-k-closest-elements/?show=1) | +| [74. Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix/?show=1) | [74. 搜索二维矩阵](https://leetcode.cn/problems/search-a-2d-matrix/?show=1) | +| [793. Preimage Size of Factorial Zeroes Function](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/?show=1) | [793. 阶乘函数后 K 个零](https://leetcode.cn/problems/preimage-size-of-factorial-zeroes-function/?show=1) | +| [81. Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii/?show=1) | [81. 搜索旋转排序数组 II](https://leetcode.cn/problems/search-in-rotated-sorted-array-ii/?show=1) | +| [852. Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array/?show=1) | [852. 山脉数组的峰顶索引](https://leetcode.cn/problems/peak-index-in-a-mountain-array/?show=1) | +| - | [剑指 Offer 04. 二维数组中的查找](https://leetcode.cn/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/?show=1) | +| - | [剑指 Offer 53 - I. 在排序数组中查找数字 I](https://leetcode.cn/problems/zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof/?show=1) | +| - | [剑指 Offer 53 - II. 0〜n-1中缺失的数字](https://leetcode.cn/problems/que-shi-de-shu-zi-lcof/?show=1) | +| - | [剑指 Offer II 068. 查找插入位置](https://leetcode.cn/problems/N6YdxV/?show=1) | +| - | [剑指 Offer II 069. 山峰数组的顶部](https://leetcode.cn/problems/B1IidL/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円207円240円344円270円252円345円217円215円347円233円264円350円247円211円347円232円204円346円246円202円347円216円207円351円227円256円351円242円230円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円207円240円344円270円252円345円217円215円347円233円264円350円247円211円347円232円204円346円246円202円347円216円207円351円227円256円351円242円230円.md" index f8e389e4ad..fed3035609 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円207円240円344円270円252円345円217円215円347円233円264円350円247円211円347円232円204円346円246円202円347円216円207円351円227円256円351円242円230円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円207円240円344円270円252円345円217円215円347円233円264円350円247円211円347円232円204円346円246円202円347円216円207円351円227円256円351円242円230円.md" @@ -9,13 +9,13 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** **-----------** -上篇文章 [洗牌算法详解](https://labuladong.github.io/article/fname.html?fname=洗牌算法) 讲到了验证概率算法的蒙特卡罗方法,今天聊点轻松的内容:几个和概率相关的有趣问题。 +上篇文章 [谈谈游戏中的随机算法](https://labuladong.github.io/article/fname.html?fname=随机算法) 讲到了验证概率算法的蒙特卡罗方法,今天聊点轻松的内容:几个和概率相关的有趣问题。 计算概率有下面两个最简单的原则: @@ -133,7 +133,7 @@ **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円211円215円347円274円200円345円222円214円346円212円200円345円267円247円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円211円215円347円274円200円345円222円214円346円212円200円345円267円247円.md" index 0886e61c1c..44f9ee5bd2 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円211円215円347円274円200円345円222円214円346円212円200円345円267円247円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円211円215円347円274円200円345円222円214円346円212円200円345円267円247円.md" @@ -1,13 +1,5 @@ # 经典数组技巧:前缀和数组 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -185,6 +177,55 @@ class NumMatrix { 除了本文举例的基本用法,前缀和数组经常和其他数据结构或算法技巧相结合,我会在 [前缀和技巧高频习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_627cd61de4b0cedf38b0f3a0/1) 中举例讲解。 + + +


+
+引用本文的文章 + + - [二维数组的花式遍历技巧](https://labuladong.github.io/article/fname.html?fname=花式遍历) + - [动态规划设计:最大子数组](https://labuladong.github.io/article/fname.html?fname=最大子数组) + - [小而美的算法技巧:差分数组](https://labuladong.github.io/article/fname.html?fname=差分技巧) + - [带权重的随机选择算法](https://labuladong.github.io/article/fname.html?fname=随机权重) + - [归并排序详解及应用](https://labuladong.github.io/article/fname.html?fname=归并排序) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1314. Matrix Block Sum](https://leetcode.com/problems/matrix-block-sum/?show=1) | [1314. 矩阵区域和](https://leetcode.cn/problems/matrix-block-sum/?show=1) | +| [1352. Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers/?show=1) | [1352. 最后 K 个数的乘积](https://leetcode.cn/problems/product-of-the-last-k-numbers/?show=1) | +| [238. Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/?show=1) | [238. 除自身以外数组的乘积](https://leetcode.cn/problems/product-of-array-except-self/?show=1) | +| [327. Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/?show=1) | [327. 区间和的个数](https://leetcode.cn/problems/count-of-range-sum/?show=1) | +| [437. Path Sum III](https://leetcode.com/problems/path-sum-iii/?show=1) | [437. 路径总和 III](https://leetcode.cn/problems/path-sum-iii/?show=1) | +| [523. Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum/?show=1) | [523. 连续的子数组和](https://leetcode.cn/problems/continuous-subarray-sum/?show=1) | +| [525. Contiguous Array](https://leetcode.com/problems/contiguous-array/?show=1) | [525. 连续数组](https://leetcode.cn/problems/contiguous-array/?show=1) | +| [560. Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k/?show=1) | [560. 和为 K 的子数组](https://leetcode.cn/problems/subarray-sum-equals-k/?show=1) | +| [724. Find Pivot Index](https://leetcode.com/problems/find-pivot-index/?show=1) | [724. 寻找数组的中心下标](https://leetcode.cn/problems/find-pivot-index/?show=1) | +| [862. Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/?show=1) | [862. 和至少为 K 的最短子数组](https://leetcode.cn/problems/shortest-subarray-with-sum-at-least-k/?show=1) | +| [918. Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray/?show=1) | [918. 环形子数组的最大和](https://leetcode.cn/problems/maximum-sum-circular-subarray/?show=1) | +| [974. Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k/?show=1) | [974. 和可被 K 整除的子数组](https://leetcode.cn/problems/subarray-sums-divisible-by-k/?show=1) | +| - | [剑指 Offer 57 - II. 和为s的连续正数序列](https://leetcode.cn/problems/he-wei-sde-lian-xu-zheng-shu-xu-lie-lcof/?show=1) | +| - | [剑指 Offer II 010. 和为 k 的子数组](https://leetcode.cn/problems/QTMn0o/?show=1) | +| - | [剑指 Offer II 011. 0 和 1 个数相同的子数组](https://leetcode.cn/problems/A1NYOS/?show=1) | +| - | [剑指 Offer II 012. 左右两边子数组的和相等](https://leetcode.cn/problems/tvdfij/?show=1) | +| - | [剑指 Offer II 013. 二维子矩阵的和](https://leetcode.cn/problems/O4NDxx/?show=1) | +| - | [剑指 Offer II 050. 向下的路径节点之和](https://leetcode.cn/problems/6eUYwP/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円217円214円346円214円207円351円222円210円346円212円200円345円267円247円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円217円214円346円214円207円351円222円210円346円212円200円345円267円247円.md" index fc2343365c..918bf57ced 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円217円214円346円214円207円351円222円210円346円212円200円345円267円247円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円217円214円346円214円207円351円222円210円346円212円200円345円267円247円.md" @@ -1,13 +1,5 @@ # 数组双指针技巧汇总 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -387,6 +379,51 @@ String longestPalindrome(String s) { 到这里,数组相关的双指针技巧就全部讲完了,这些技巧的更多扩展延伸见 [更多双指针经典高频题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a1dd68e4b09dda1273a5f9/1)。 + + +


+
+引用本文的文章 + + - [一个方法团灭 nSum 问题](https://labuladong.github.io/article/fname.html?fname=nSum) + - [分治算法详解:运算优先级](https://labuladong.github.io/article/fname.html?fname=分治算法) + - [动态规划之子序列问题解题模板](https://labuladong.github.io/article/fname.html?fname=子序列问题模板) + - [双指针更多经典习题](https://appktavsiei5995.pc.xiaoe-tech.com/detail/i_62a1dd68e4b09dda1273a5f9/1) + - [如何判断回文链表](https://labuladong.github.io/article/fname.html?fname=判断回文链表) + - [我写了首诗,把滑动窗口算法变成了默写题](https://labuladong.github.io/article/fname.html?fname=滑动窗口技巧进阶) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + - [扫描线技巧:安排会议室](https://labuladong.github.io/article/fname.html?fname=安排会议室) + - [田忌赛马背后的算法决策](https://labuladong.github.io/article/fname.html?fname=田忌赛马) + - [算法时空复杂度分析实用指南](https://labuladong.github.io/article/fname.html?fname=时间复杂度) + - [算法笔试「骗分」套路](https://labuladong.github.io/article/fname.html?fname=刷题技巧) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [1. Two Sum](https://leetcode.com/problems/two-sum/?show=1) | [1. 两数之和](https://leetcode.cn/problems/two-sum/?show=1) | +| [281. Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator/?show=1)🔒 | [281. 锯齿迭代器](https://leetcode.cn/problems/zigzag-iterator/?show=1)🔒 | +| [42. Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/?show=1) | [42. 接雨水](https://leetcode.cn/problems/trapping-rain-water/?show=1) | +| [658. Find K Closest Elements](https://leetcode.com/problems/find-k-closest-elements/?show=1) | [658. 找到 K 个最接近的元素](https://leetcode.cn/problems/find-k-closest-elements/?show=1) | +| [80. Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/?show=1) | [80. 删除有序数组中的重复项 II](https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/?show=1) | +| [82. Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/?show=1) | [82. 删除排序链表中的重复元素 II](https://leetcode.cn/problems/remove-duplicates-from-sorted-list-ii/?show=1) | +| [9. Palindrome Number](https://leetcode.com/problems/palindrome-number/?show=1) | [9. 回文数](https://leetcode.cn/problems/palindrome-number/?show=1) | +| - | [剑指 Offer 21. 调整数组顺序使奇数位于偶数前面](https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/?show=1) | +| - | [剑指 Offer 57. 和为s的两个数字](https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円233円236円346円272円257円347円256円227円346円263円225円350円257円246円350円247円243円344円277円256円350円256円242円347円211円210円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円233円236円346円272円257円347円256円227円346円263円225円350円257円246円350円247円243円344円277円256円350円256円242円347円211円210円.md" index 2696585942..8f9a57af8e 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円233円236円346円272円257円347円256円227円346円263円225円350円257円246円350円247円243円344円277円256円350円256円242円347円211円210円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円233円236円346円272円257円347円256円227円346円263円225円350円257円246円350円247円243円344円277円256円350円256円242円347円211円210円.md" @@ -1,11 +1,5 @@ # 回溯算法详解 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -335,6 +329,67 @@ def backtrack(...): 动态规划和回溯算法底层都把问题抽象成了树的结构,但这两种算法在思路上是完全不同的。在 [东哥带你刷二叉树(纲领篇)](https://labuladong.github.io/article/fname.html?fname=二叉树总结) 你将看到动态规划和回溯算法更深层次的区别和联系。 + + +


+
+引用本文的文章 + + - [BFS 算法解题套路框架](https://labuladong.github.io/article/fname.html?fname=BFS框架) + - [Dijkstra 算法模板及应用](https://labuladong.github.io/article/fname.html?fname=dijkstra算法) + - [FloodFill算法详解及应用](https://labuladong.github.io/article/fname.html?fname=FloodFill算法详解及应用) + - [base case 和备忘录的初始值怎么定?](https://labuladong.github.io/article/fname.html?fname=备忘录等基础) + - [东哥带你刷二叉树(纲领篇)](https://labuladong.github.io/article/fname.html?fname=二叉树总结) + - [两种思路解决单词拼接问题](https://labuladong.github.io/article/fname.html?fname=单词拼接) + - [二分搜索怎么用?我和快手面试官进行了深度探讨](https://labuladong.github.io/article/fname.html?fname=二分分割子数组) + - [分治算法详解:运算优先级](https://labuladong.github.io/article/fname.html?fname=分治算法) + - [前缀树算法模板秒杀五道算法题](https://labuladong.github.io/article/fname.html?fname=trie) + - [动态规划和回溯算法到底谁是谁爹?](https://labuladong.github.io/article/fname.html?fname=targetSum) + - [回溯算法最佳实践:括号生成](https://labuladong.github.io/article/fname.html?fname=合法括号生成) + - [回溯算法最佳实践:解数独](https://labuladong.github.io/article/fname.html?fname=sudoku) + - [回溯算法秒杀所有排列/组合/子集问题](https://labuladong.github.io/article/fname.html?fname=子集排列组合) + - [图论基础及遍历算法](https://labuladong.github.io/article/fname.html?fname=图) + - [学习算法和刷题的框架思维](https://labuladong.github.io/article/fname.html?fname=学习数据结构和算法的高效方法) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + - [环检测及拓扑排序算法](https://labuladong.github.io/article/fname.html?fname=拓扑排序) + - [算法学习和心流体验](https://labuladong.github.io/article/fname.html?fname=心流) + - [算法笔试「骗分」套路](https://labuladong.github.io/article/fname.html?fname=刷题技巧) + - [经典动态规划:戳气球](https://labuladong.github.io/article/fname.html?fname=扎气球) + - [经典回溯算法:集合划分问题](https://labuladong.github.io/article/fname.html?fname=集合划分) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [112. Path Sum](https://leetcode.com/problems/path-sum/?show=1) | [112. 路径总和](https://leetcode.cn/problems/path-sum/?show=1) | +| [113. Path Sum II](https://leetcode.com/problems/path-sum-ii/?show=1) | [113. 路径总和 II](https://leetcode.cn/problems/path-sum-ii/?show=1) | +| [140. Word Break II](https://leetcode.com/problems/word-break-ii/?show=1) | [140. 单词拆分 II](https://leetcode.cn/problems/word-break-ii/?show=1) | +| [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/?show=1) | [17. 电话号码的字母组合](https://leetcode.cn/problems/letter-combinations-of-a-phone-number/?show=1) | +| [22. Generate Parentheses](https://leetcode.com/problems/generate-parentheses/?show=1) | [22. 括号生成](https://leetcode.cn/problems/generate-parentheses/?show=1) | +| [39. Combination Sum](https://leetcode.com/problems/combination-sum/?show=1) | [39. 组合总和](https://leetcode.cn/problems/combination-sum/?show=1) | +| [698. Partition to K Equal Sum Subsets](https://leetcode.com/problems/partition-to-k-equal-sum-subsets/?show=1) | [698. 划分为k个相等的子集](https://leetcode.cn/problems/partition-to-k-equal-sum-subsets/?show=1) | +| [77. Combinations](https://leetcode.com/problems/combinations/?show=1) | [77. 组合](https://leetcode.cn/problems/combinations/?show=1) | +| [78. Subsets](https://leetcode.com/problems/subsets/?show=1) | [78. 子集](https://leetcode.cn/problems/subsets/?show=1) | +| - | [剑指 Offer 34. 二叉树中和为某一值的路径](https://leetcode.cn/problems/er-cha-shu-zhong-he-wei-mou-yi-zhi-de-lu-jing-lcof/?show=1) | +| - | [剑指 Offer II 079. 所有子集](https://leetcode.cn/problems/TVdhkn/?show=1) | +| - | [剑指 Offer II 080. 含有 k 个元素的组合](https://leetcode.cn/problems/uUsW3B/?show=1) | +| - | [剑指 Offer II 081. 允许重复选择元素的组合](https://leetcode.cn/problems/Ygoe9J/?show=1) | +| - | [剑指 Offer II 083. 没有重复元素集合的全排列](https://leetcode.cn/problems/VvJkup/?show=1) | +| - | [剑指 Offer II 085. 生成匹配的括号](https://leetcode.cn/problems/IDBivT/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円227円347円254円246円344円270円262円344円271円230円346円263円225円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円227円347円254円246円344円270円262円344円271円230円346円263円225円.md" index b285fb9c32..b4512e9e4d 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円227円347円254円246円344円270円262円344円271円230円346円263円225円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円227円347円254円246円344円270円262円344円271円230円346円263円225円.md" @@ -1,11 +1,5 @@ # 字符串乘法 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -100,6 +94,10 @@ string multiply(string num1, string num2) { 也许算法就是一种**寻找思维定式的思维**吧,希望本文对你有帮助。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円246円344円271円240円346円225円260円346円215円256円347円273円223円346円236円204円345円222円214円347円256円227円346円263円225円347円232円204円351円253円230円346円225円210円346円226円271円346円263円225円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円246円344円271円240円346円225円260円346円215円256円347円273円223円346円236円204円345円222円214円347円256円227円346円263円225円347円232円204円351円253円230円346円225円210円346円226円271円346円263円225円.md" index 33e458980b..38a74434f2 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円246円344円271円240円346円225円260円346円215円256円347円273円223円346円236円204円345円222円214円347円256円227円346円263円225円347円232円204円351円253円230円346円225円210円346円226円271円346円263円225円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円255円246円344円271円240円346円225円260円346円215円256円347円273円223円346円236円204円345円222円214円347円256円227円346円263円225円347円232円204円351円253円230円346円225円210円346円226円271円346円263円225円.md" @@ -1,4 +1,4 @@ -# 学习算法和刷题的思路指南 +# 学习数据结构和算法的框架思维

GitHub @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -350,6 +350,7 @@ N 叉树的遍历框架,找出来了吧?你说,树这种结构重不重要 - [图论基础及遍历算法](https://labuladong.github.io/article/fname.html?fname=图) - [如何 K 个一组反转链表](https://labuladong.github.io/article/fname.html?fname=k个一组反转链表) - [如何判断回文链表](https://labuladong.github.io/article/fname.html?fname=判断回文链表) + - [存储系统设计之 LSM 树原理](https://labuladong.github.io/article/fname.html?fname=LSM树) - [归并排序详解及应用](https://labuladong.github.io/article/fname.html?fname=归并排序) - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) - [环检测及拓扑排序算法](https://labuladong.github.io/article/fname.html?fname=拓扑排序) @@ -381,7 +382,7 @@ N 叉树的遍历框架,找出来了吧?你说,树这种结构重不重要 **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円267円256円345円210円206円346円212円200円345円267円247円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円267円256円345円210円206円346円212円200円345円267円247円.md" index b5b3eefc82..2ad5b80781 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円267円256円345円210円206円346円212円200円345円267円247円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円267円256円345円210円206円346円212円200円345円267円247円.md" @@ -1,4 +1,4 @@ -# 那些小而美的算法技巧:前缀和/差分数组 +# 经典数组技巧:差分数组

GitHub @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -275,7 +275,7 @@ boolean carPooling(int[][] trips, int capacity) { 最后,差分数组和前缀和数组都是比较常见且巧妙的算法技巧,分别适用不同的场景,而且是会者不难,难者不会。所以,关于差分数组的使用,你学会了吗? -> 最后打个广告,我亲自制作了一门 [数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO),以视频课为主,手把手带你实现常用的数据结构及相关算法,旨在帮助算法基础较为薄弱的读者深入理解常用数据结构的底层原理,在算法学习中少走弯路。 +更多经典的数组/链表技巧习题见 [数组链表解题技巧精讲](https://appktavsiei5995.pc.xiaoe-tech.com/detail/p_62655effe4b0812e1790ecd7/6)。 @@ -295,6 +295,6 @@ boolean carPooling(int[][] trips, int capacity) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円270円270円347円224円250円347円232円204円344円275円215円346円223円215円344円275円234円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円270円270円347円224円250円347円232円204円344円275円215円346円223円215円344円275円234円.md" index d109f1f3f0..2fb413a9ad 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円270円270円347円224円250円347円232円204円344円275円215円346円223円215円344円275円234円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/345円270円270円347円224円250円347円232円204円344円275円215円346円223円215円344円275円234円.md" @@ -1,9 +1,5 @@ # 常用的位运算技巧 - - - -

GitHub @@ -13,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -247,6 +243,35 @@ int missingNumber(int[] nums) { http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel + + +


+
+引用本文的文章 + + - [丑数系列算法详解](https://labuladong.github.io/article/fname.html?fname=丑数) + - [如何同时寻找缺失和重复的元素](https://labuladong.github.io/article/fname.html?fname=缺失和重复的元素) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [389. Find the Difference](https://leetcode.com/problems/find-the-difference/?show=1) | [389. 找不同](https://leetcode.cn/problems/find-the-difference/?show=1) | +| - | [剑指 Offer 15. 二进制中1的个数](https://leetcode.cn/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円264円227円347円211円214円347円256円227円346円263円225円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円264円227円347円211円214円347円256円227円346円263円225円.md" index b7fc9a37d7..c53f3d2a62 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円264円227円347円211円214円347円256円227円346円263円225円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円264円227円347円211円214円347円256円227円346円263円225円.md" @@ -1,7 +1,5 @@ # 洗牌算法 - -

GitHub @@ -11,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -204,6 +202,10 @@ for (int feq : count) 第二部分写了洗牌算法正确性的衡量标准,即每种随机结果出现的概率必须相等。如果我们不用严格的数学证明,可以通过蒙特卡罗方法大力出奇迹,粗略验证算法的正确性。蒙特卡罗方法也有不同的思路,不过要求不必太严格,因为我们只是寻求一个简单的验证。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円273円221円345円212円250円347円252円227円345円217円243円346円212円200円345円267円247円350円277円233円351円230円266円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円273円221円345円212円250円347円252円227円345円217円243円346円212円200円345円267円247円350円277円233円351円230円266円.md" index dccf74541a..95568c7a0c 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円273円221円345円212円250円347円252円227円345円217円243円346円212円200円345円267円247円350円277円233円351円230円266円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/346円273円221円345円212円250円347円252円227円345円217円243円346円212円200円345円267円247円350円277円233円351円230円266円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -314,7 +314,7 @@ bool checkInclusion(string t, string s) { 对于这道题的解法代码,基本上和最小覆盖子串一模一样,只需要改变几个地方: -1、本题移动 `left` 缩小窗口的时机是窗口大小大于 `t.size()` 时,应为排列嘛,显然长度应该是一样的。 +1、本题移动 `left` 缩小窗口的时机是窗口大小大于 `t.size()` 时,因为排列嘛,显然长度应该是一样的。 2、当发现 `valid == need.size()` 时,就说明窗口中就是一个合法的排列,所以立即返回 `true`。 @@ -476,6 +476,6 @@ int lengthOfLongestSubstring(string s) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/347円203円247円351円245円274円346円216円222円345円272円217円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/347円203円247円351円245円274円346円216円222円345円272円217円.md" index 1ac34a4a60..c31356d8c4 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/347円203円247円351円245円274円346円216円222円345円272円217円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/347円203円247円351円245円274円346円216円222円345円272円217円.md" @@ -1,11 +1,5 @@ # 烧饼排序 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -148,6 +142,10 @@ void reverse(int[] arr, int i, int j) { 不妨分享一下你的思考。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/350円212円261円345円274円217円351円201円215円345円216円206円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/350円212円261円345円274円217円351円201円215円345円216円206円.md" index b370ee1c84..679dc46581 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/350円212円261円345円274円217円351円201円215円345円216円206円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/350円212円261円345円274円217円351円201円215円345円216円206円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -326,6 +326,6 @@ int[][] generateMatrix(int n) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/351円233円206円345円220円210円345円210円222円345円210円206円.md" "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/351円233円206円345円220円210円345円210円222円345円210円206円.md" index 8092d38a92..602b1d99b8 100644 --- "a/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/351円233円206円345円220円210円345円210円222円345円210円206円.md" +++ "b/347円256円227円346円263円225円346円200円235円347円273円264円347円263円273円345円210円227円/351円233円206円345円220円210円345円210円222円345円210円206円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -568,6 +568,6 @@ boolean backtrack(int k, int bucket, **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/LRU347円256円227円346円263円225円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/LRU347円256円227円346円263円225円.md" index 4710011e8c..0bd9bf33b4 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/LRU347円256円227円346円263円225円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/LRU347円256円227円346円263円225円.md" @@ -1,13 +1,5 @@ # LRU 缓存淘汰算法设计 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -350,6 +342,37 @@ class LRUCache { * [手把手带你实现 LFU 算法](https://labuladong.github.io/article/fname.html?fname=LFU) + + +


+
+引用本文的文章 + + - [一文看懂 session 和 cookie](https://labuladong.github.io/article/fname.html?fname=session和cookie) + - [常数时间删除/查找数组中的任意元素](https://labuladong.github.io/article/fname.html?fname=随机集合) + - [数据结构设计:最大栈](https://labuladong.github.io/article/fname.html?fname=最大栈) + - [算法就像搭乐高:带你手撸 LFU 算法](https://labuladong.github.io/article/fname.html?fname=LFU) + - [算法笔试「骗分」套路](https://labuladong.github.io/article/fname.html?fname=刷题技巧) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| - | [剑指 Offer II 031. 最近最少使用缓存](https://leetcode.cn/problems/OrIXps/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/k344円270円252円344円270円200円347円273円204円345円217円215円350円275円254円351円223円276円350円241円250円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/k344円270円252円344円270円200円347円273円204円345円217円215円350円275円254円351円223円276円350円241円250円.md" index fc18a966d7..3cead0d137 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/k344円270円252円344円270円200円347円273円204円345円217円215円350円275円254円351円223円276円350円241円250円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/k344円270円252円344円270円200円347円273円204円345円217円215円350円275円254円351円223円276円350円241円250円.md" @@ -1,13 +1,5 @@ # 如何k个一组反转链表 - - - - - - - -

GitHub @@ -17,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -157,6 +149,34 @@ ListNode reverseKGroup(ListNode head, int k) { 那么如何分解问题、发现递归性质呢?这个只能多练习,我在数据结构精品课中讲解了 [单链表的递归实现](https://aep.h5.xeknow.com/s/1RQzXc),应该能够让你进一步加深对递归的理解。 + + +


+
+引用本文的文章 + + - [东哥带你刷二叉树(思路篇)](https://labuladong.github.io/article/fname.html?fname=二叉树系列1) + - [算法笔试「骗分」套路](https://labuladong.github.io/article/fname.html?fname=刷题技巧) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [24. Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/?show=1) | [24. 两两交换链表中的节点](https://leetcode.cn/problems/swap-nodes-in-pairs/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円270円200円350円241円214円344円273円243円347円240円201円350円247円243円345円206円263円347円232円204円346円231円272円345円212円233円351円242円230円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円270円200円350円241円214円344円273円243円347円240円201円350円247円243円345円206円263円347円232円204円346円231円272円345円212円233円351円242円230円.md" index d46dc767e8..b6a4e96e0b 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円270円200円350円241円214円344円273円243円347円240円201円350円247円243円345円206円263円347円232円204円346円231円272円345円212円233円351円242円230円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円270円200円350円241円214円344円273円243円347円240円201円350円247円243円345円206円263円347円232円204円346円231円272円345円212円233円351円242円230円.md" @@ -1,11 +1,5 @@ # 一行代码就能解决的算法题 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -147,6 +141,22 @@ int bulbSwitch(int n) { 就算有的 `n` 平方根结果是小数,强转成 int 型,也相当于一个最大整数上界,比这个上界小的所有整数,平方后的索引都是最后亮着的灯的索引。所以说我们直接把平方根转成整数,就是这个问题的答案。 + + +


+
+引用本文的文章 + + - [丑数系列算法详解](https://labuladong.github.io/article/fname.html?fname=丑数) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + - [经典动态规划:博弈问题](https://labuladong.github.io/article/fname.html?fname=动态规划之博弈问题) + +

+ + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円345円210円244円345円256円232円345円255円220円345円272円217円345円210円227円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円345円210円244円345円256円232円345円255円220円345円272円217円345円210円227円.md" index efe18606b2..e80766bd40 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円345円210円244円345円256円232円345円255円220円345円272円217円345円210円227円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円346円237円245円346円211円276円345円210円244円345円256円232円345円255円220円345円272円217円345円210円227円.md" @@ -1,11 +1,5 @@ # 二分查找高效判定子序列 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -232,6 +226,10 @@ int left_bound(ArrayList arr, int target) { } ``` + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円350円277円220円347円224円250円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円350円277円220円347円224円250円.md" index 5eb132beb5..3ee95ca877 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円350円277円220円347円224円250円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/344円272円214円345円210円206円350円277円220円347円224円250円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円210円244円346円226円255円345円233円236円346円226円207円351円223円276円350円241円250円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円210円244円346円226円255円345円233円236円346円226円207円351円223円276円350円241円250円.md" index 6a3da5d1f2..f92931d306 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円210円244円346円226円255円345円233円236円346円226円207円351円223円276円350円241円250円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円210円244円346円226円255円345円233円236円346円226円207円351円223円276円350円241円250円.md" @@ -1,11 +1,5 @@ # 如何高效判断回文链表 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -267,6 +261,23 @@ p.next = reverse(q); > 最后打个广告,我亲自制作了一门 [数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO),以视频课为主,手把手带你实现常用的数据结构及相关算法,旨在帮助算法基础较为薄弱的读者深入理解常用数据结构的底层原理,在算法学习中少走弯路。 + + + +


+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| - | [剑指 Offer II 027. 回文链表](https://leetcode.cn/problems/aMhZSa/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円220円215円344円272円272円351円227円256円351円242円230円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円220円215円344円272円272円351円227円256円351円242円230円.md" index c298104deb..1b7433884d 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円220円215円344円272円272円351円227円256円351円242円230円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円220円215円344円272円272円351円227円256円351円242円230円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -269,6 +269,6 @@ int findCelebrity(int n) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円255円220円351円233円206円346円216円222円345円210円227円347円273円204円345円220円210円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円255円220円351円233円206円346円216円222円345円210円227円347円273円204円345円220円210円.md" index f14d864d28..5fb6dc84e4 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円255円220円351円233円206円346円216円222円345円210円227円347円273円204円345円220円210円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円255円220円351円233円206円346円216円222円345円210円227円347円273円204円345円220円210円.md" @@ -1,11 +1,5 @@ # 一文秒杀所有排列组合子集问题 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -924,6 +918,43 @@ void backtrack(int[] nums) { 如果你能够看到这里,真得给你鼓掌,相信你以后遇到各种乱七八糟的算法题,也能一眼看透它们的本质,以不变应万变。另外,考虑到篇幅,本文并没有对这些算法进行复杂度的分析,你可以使用我在 [算法时空复杂度分析实用指南](https://labuladong.github.io/article/fname.html?fname=时间复杂度) 讲到的复杂度分析方法尝试自己分析它们的复杂度。 + + +


+
+引用本文的文章 + + - [两种思路解决单词拼接问题](https://labuladong.github.io/article/fname.html?fname=单词拼接) + - [分治算法详解:运算优先级](https://labuladong.github.io/article/fname.html?fname=分治算法) + - [回溯算法解题套路框架](https://labuladong.github.io/article/fname.html?fname=回溯算法详解修订版) + - [我的刷题心得](https://labuladong.github.io/article/fname.html?fname=算法心得) + - [算法时空复杂度分析实用指南](https://labuladong.github.io/article/fname.html?fname=时间复杂度) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/?show=1) | [17. 电话号码的字母组合](https://leetcode.cn/problems/letter-combinations-of-a-phone-number/?show=1) | +| [491. Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences/?show=1) | [491. 递增子序列](https://leetcode.cn/problems/increasing-subsequences/?show=1) | +| - | [剑指 Offer 38. 字符串的排列](https://leetcode.cn/problems/zi-fu-chuan-de-pai-lie-lcof/?show=1) | +| - | [剑指 Offer II 079. 所有子集](https://leetcode.cn/problems/TVdhkn/?show=1) | +| - | [剑指 Offer II 080. 含有 k 个元素的组合](https://leetcode.cn/problems/uUsW3B/?show=1) | +| - | [剑指 Offer II 081. 允许重复选择元素的组合](https://leetcode.cn/problems/Ygoe9J/?show=1) | +| - | [剑指 Offer II 083. 没有重复元素集合的全排列](https://leetcode.cn/problems/VvJkup/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円256円211円346円216円222円344円274円232円350円256円256円345円256円244円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円256円211円346円216円222円344円274円232円350円256円256円345円256円244円.md" index 89b1b3171a..4e2a7ab691 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円256円211円346円216円222円344円274円232円350円256円256円345円256円244円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円256円211円346円216円222円344円274円232円350円256円256円345円256円244円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -197,6 +197,6 @@ int minMeetingRooms(int[][] meetings) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円262円233円345円261円277円351円242円230円347円233円256円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円262円233円345円261円277円351円242円230円347円233円256円.md" index 85b30e811c..0ea057e647 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円262円233円345円261円277円351円242円230円347円233円256円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円262円233円345円261円277円351円242円230円347円233円256円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -529,6 +529,6 @@ int numDistinctIslands(int[][] grid) { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png) \ No newline at end of file diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円272円247円344円275円215円350円260円203円345円272円246円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円272円247円344円275円215円350円260円203円345円272円246円.md" index 105bccef76..327b8d68b5 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円272円247円344円275円215円350円260円203円345円272円246円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/345円272円247円344円275円215円350円260円203円345円272円246円.md" @@ -1,11 +1,5 @@ # 如何调度考生的座位 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -230,6 +224,10 @@ private int distance(int[] intv) { 希望本文对大家有帮助。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円211円223円345円215円260円347円264円240円346円225円260円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円211円223円345円215円260円347円264円240円346円225円260円.md" index 8ad84f7397..2cf1e0a4b4 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円211円223円345円215円260円347円264円240円346円225円260円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円211円223円345円215円260円347円264円240円346円225円260円.md" @@ -1,11 +1,5 @@ # 如何高效寻找素数 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -180,6 +174,33 @@ int countPrimes(int n) { 以上就是素数算法相关的全部内容。怎么样,是不是看似简单的问题却有不少细节可以打磨呀? + + +


+
+引用本文的文章 + + - [丑数系列算法详解](https://labuladong.github.io/article/fname.html?fname=丑数) + +

+ + + + +
+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [264. Ugly Number II](https://leetcode.com/problems/ugly-number-ii/?show=1) | [264. 丑数 II](https://leetcode.cn/problems/ugly-number-ii/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円216円245円351円233円250円346円260円264円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円216円245円351円233円250円346円260円264円.md" index 8a7b6f6111..3ad805d92a 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円216円245円351円233円250円346円260円264円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円216円245円351円233円250円346円260円264円.md" @@ -1,11 +1,7 @@ # 接雨水问题详解 - + - - - -

GitHub @@ -15,7 +11,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -280,6 +276,10 @@ if (height[left] < height[right]) { 至此,这道题也解决了。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円260円264円345円241円230円346円212円275円346円240円267円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円260円264円345円241円230円346円212円275円346円240円267円.md" index 574bef3d80..1ecb4f447f 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円260円264円345円241円230円346円212円275円346円240円267円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/346円260円264円345円241円230円346円212円275円346円240円267円.md" @@ -1,11 +1,5 @@ # 随机算法之水塘抽样算法 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -130,6 +124,10 @@ int[] getRandom(ListNode head, int k) { 答案见 [我的这篇文章](https://labuladong.github.io/article/fname.html?fname=随机集合)。 + + + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/347円274円272円345円244円261円345円222円214円351円207円215円345円244円215円347円232円204円345円205円203円347円264円240円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/347円274円272円345円244円261円345円222円214円351円207円215円345円244円215円347円232円204円345円205円203円347円264円240円.md" index c6a76307f7..baf9b8c07f 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/347円274円272円345円244円261円345円222円214円351円207円215円345円244円215円347円232円204円345円205円203円347円264円240円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/347円274円272円345円244円261円345円222円214円351円207円215円345円244円215円347円232円204円345円205円203円347円264円240円.md" @@ -1,11 +1,5 @@ # 如何寻找缺失和重复的元素 - - - - - -

GitHub @@ -15,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -134,6 +128,24 @@ int[] findErrorNums(int[] nums) { 异或运算也是常用的,因为异或性质 `a ^ a = 0, a ^ 0 = a`,如果将索引和元素同时异或,就可以消除成对儿的索引和元素,留下的就是重复或者缺失的元素。可以看看前文 [常用的位运算](https://labuladong.github.io/article/fname.html?fname=常用的位操作),介绍过这种方法。 + + + +


+
+引用本文的题目 + +安装 [我的 Chrome 刷题插件](https://mp.weixin.qq.com/s/X-fE9sR4BLi6T9pn7xP4pg) 点开下列题目可直接查看解题思路: + +| LeetCode | 力扣 | +| :----: | :----: | +| [442. Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array/?show=1) | [442. 数组中重复的数据](https://leetcode.cn/problems/find-all-duplicates-in-an-array/?show=1) | +| [448. Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/?show=1) | [448. 找到所有数组中消失的数字](https://leetcode.cn/problems/find-all-numbers-disappeared-in-an-array/?show=1) | + +
+ + + **_____________** **《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: diff --git "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/351円232円217円346円234円272円346円235円203円351円207円215円.md" "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/351円232円217円346円234円272円346円235円203円351円207円215円.md" index f89fdc28a1..5c03e74fce 100644 --- "a/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/351円232円217円346円234円272円346円235円203円351円207円215円.md" +++ "b/351円253円230円351円242円221円351円235円242円350円257円225円347円263円273円345円210円227円/351円232円217円346円234円272円346円235円203円351円207円215円.md" @@ -9,7 +9,7 @@ ![](https://labuladong.github.io/algo/images/souyisou1.png) -**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V1.9,[第 11 期刷题打卡挑战(9/19 开始)](https://mp.weixin.qq.com/s/eUG2OOzY3k_ZTz-CFvtv5Q) 开始报名。另外,建议你在我的 [网站](https://labuladong.github.io/algo/) 学习文章,体验更好。** +**通知:[数据结构精品课](https://aep.h5.xeknow.com/s/1XJHEO) 已更新到 V2.0,第 12 期刷题打卡 [开始报名](https://aep.xet.tech/s/XhcRc),点击这里体验 [刷题全家桶](https://labuladong.gitee.io/algo/images/others/%E5%85%A8%E5%AE%B6%E6%A1%B6.jpg)。另外,建议你在我的 [网站](https://labuladong.gitee.io/algo/) 学习文章,体验更好。** @@ -58,7 +58,7 @@ 前文 [设计随机删除元素的数据结构](https://labuladong.github.io/article/fname.html?fname=随机集合) 主要考察的是数据结构的使用,每次把元素移到数组尾部再删除,可以避免数据搬移。 -前文 [无限序列中随机抽取元素](https://labuladong.github.io/article/fname.html?fname=水塘抽样) 讲的是经典的「水塘抽样算法」,运用简单的数学运算,在无限序列中等概率选取元素。 +前文 [谈谈游戏中的随机算法](https://labuladong.github.io/article/fname.html?fname=随机算法) 讲的是经典的「水塘抽样算法」,运用简单的数学运算,在无限序列中等概率选取元素。 前文 [算法笔试技巧](https://labuladong.github.io/article/fname.html?fname=刷题技巧) 中我还分享过一个巧用概率最大化测试用例通过率的骗分技巧。 @@ -210,7 +210,8 @@ class Solution {
引用本文的文章 - - [如何在无限序列中随机抽取元素](https://labuladong.github.io/article/fname.html?fname=水塘抽样) + - [谈谈游戏中的随机算法](https://labuladong.github.io/article/fname.html?fname=随机算法) + - [随机算法之水塘抽样算法](https://labuladong.github.io/article/fname.html?fname=水塘抽样)

@@ -220,6 +221,6 @@ class Solution { **_____________** -**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「进群」可加入算法群;回复「PDF」可获取精华文章 PDF**: +**《labuladong 的算法小抄》已经出版,关注公众号查看详情;后台回复关键词「**进群**」可加入算法群;回复「**全家桶**」可下载配套 PDF 和刷题全家桶**: ![](https://labuladong.github.io/algo/images/souyisou2.png)

AltStyle によって変換されたページ (->オリジナル) /