Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wmsofts
Fucking Algorithm
提交
cfdfa288
F
Fucking Algorithm
项目概览
wmsofts
/
Fucking Algorithm
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Fucking Algorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cfdfa288
编写于
11月 12, 2020
作者:
N
ningwei.shi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/labuladong/fucking-algorithm
into master
上级
4fa39a5a
36f59b6f
变更
66
隐藏空白更改
内联
并排
Showing
66 changed file
with
417 addition
and
89 deletion
+417
-89
动态规划系列/动态规划之KMP字符匹配算法.md
动态规划系列/动态规划之KMP字符匹配算法.md
+4
-1
动态规划系列/动态规划之博弈问题.md
动态规划系列/动态规划之博弈问题.md
+74
-1
动态规划系列/动态规划之四键键盘.md
动态规划系列/动态规划之四键键盘.md
+4
-1
动态规划系列/动态规划之正则表达.md
动态规划系列/动态规划之正则表达.md
+2
-1
动态规划系列/动态规划设计:最长递增子序列.md
动态规划系列/动态规划设计:最长递增子序列.md
+4
-1
动态规划系列/动态规划详解进阶.md
动态规划系列/动态规划详解进阶.md
+4
-1
动态规划系列/团灭股票问题.md
动态规划系列/团灭股票问题.md
+4
-1
动态规划系列/子序列问题模板.md
动态规划系列/子序列问题模板.md
+5
-2
动态规划系列/抢房子.md
动态规划系列/抢房子.md
+3
-3
动态规划系列/最优子结构.md
动态规划系列/最优子结构.md
+5
-2
动态规划系列/最长公共子序列.md
动态规划系列/最长公共子序列.md
+4
-1
动态规划系列/编辑距离.md
动态规划系列/编辑距离.md
+4
-1
动态规划系列/贪心算法之区间调度问题.md
动态规划系列/贪心算法之区间调度问题.md
+4
-1
动态规划系列/高楼扔鸡蛋进阶.md
动态规划系列/高楼扔鸡蛋进阶.md
+4
-1
动态规划系列/高楼扔鸡蛋问题.md
动态规划系列/高楼扔鸡蛋问题.md
+5
-2
技术/linuxshell.md
技术/linuxshell.md
+4
-1
技术/linux进程.md
技术/linux进程.md
+4
-1
技术/redis入侵.md
技术/redis入侵.md
+5
-3
技术/session和cookie.md
技术/session和cookie.md
+5
-3
技术/在线练习平台.md
技术/在线练习平台.md
+5
-3
技术/密码技术.md
技术/密码技术.md
+3
-1
数据结构系列/二叉堆详解实现优先级队列.md
数据结构系列/二叉堆详解实现优先级队列.md
+4
-1
数据结构系列/二叉搜索树操作集锦.md
数据结构系列/二叉搜索树操作集锦.md
+4
-1
数据结构系列/单调栈.md
数据结构系列/单调栈.md
+5
-3
数据结构系列/单调队列.md
数据结构系列/单调队列.md
+4
-1
数据结构系列/实现计算器.md
数据结构系列/实现计算器.md
+5
-2
数据结构系列/设计Twitter.md
数据结构系列/设计Twitter.md
+4
-1
数据结构系列/递归反转链表的一部分.md
数据结构系列/递归反转链表的一部分.md
+4
-1
数据结构系列/队列实现栈栈实现队列.md
数据结构系列/队列实现栈栈实现队列.md
+4
-1
算法思维系列/FloodFill算法详解及应用.md
算法思维系列/FloodFill算法详解及应用.md
+4
-1
算法思维系列/UnionFind算法应用.md
算法思维系列/UnionFind算法应用.md
+4
-1
算法思维系列/UnionFind算法详解.md
算法思维系列/UnionFind算法详解.md
+4
-1
算法思维系列/twoSum问题的核心思想.md
算法思维系列/twoSum问题的核心思想.md
+4
-1
算法思维系列/为什么推荐算法4.md
算法思维系列/为什么推荐算法4.md
+4
-1
算法思维系列/二分查找详解.md
算法思维系列/二分查找详解.md
+4
-1
算法思维系列/信封嵌套问题.md
算法思维系列/信封嵌套问题.md
+4
-1
算法思维系列/几个反直觉的概率问题.md
算法思维系列/几个反直觉的概率问题.md
+4
-1
算法思维系列/前缀和技巧.md
算法思维系列/前缀和技巧.md
+4
-1
算法思维系列/区间交集问题.md
算法思维系列/区间交集问题.md
+4
-1
算法思维系列/区间调度问题之区间合并.md
算法思维系列/区间调度问题之区间合并.md
+4
-1
算法思维系列/双指针技巧.md
算法思维系列/双指针技巧.md
+4
-1
算法思维系列/回溯算法详解修订版.md
算法思维系列/回溯算法详解修订版.md
+4
-1
算法思维系列/字符串乘法.md
算法思维系列/字符串乘法.md
+5
-3
算法思维系列/学习数据结构和算法的高效方法.md
算法思维系列/学习数据结构和算法的高效方法.md
+4
-1
算法思维系列/常用的位操作.md
算法思维系列/常用的位操作.md
+4
-1
算法思维系列/洗牌算法.md
算法思维系列/洗牌算法.md
+4
-1
算法思维系列/滑动窗口技巧.md
算法思维系列/滑动窗口技巧.md
+38
-4
算法思维系列/烧饼排序.md
算法思维系列/烧饼排序.md
+4
-1
算法思维系列/算法学习之路.md
算法思维系列/算法学习之路.md
+4
-1
算法思维系列/递归详解.md
算法思维系列/递归详解.md
+4
-1
高频面试系列/LRU算法.md
高频面试系列/LRU算法.md
+4
-1
高频面试系列/koko偷香蕉.md
高频面试系列/koko偷香蕉.md
+4
-1
高频面试系列/k个一组反转链表.md
高频面试系列/k个一组反转链表.md
+4
-1
高频面试系列/一行代码解决的智力题.md
高频面试系列/一行代码解决的智力题.md
+4
-1
高频面试系列/二分查找判定子序列.md
高频面试系列/二分查找判定子序列.md
+4
-1
高频面试系列/判断回文链表.md
高频面试系列/判断回文链表.md
+4
-1
高频面试系列/合法括号判定.md
高频面试系列/合法括号判定.md
+4
-1
高频面试系列/如何去除有序数组的重复元素.md
高频面试系列/如何去除有序数组的重复元素.md
+10
-3
高频面试系列/子集排列组合.md
高频面试系列/子集排列组合.md
+5
-2
高频面试系列/座位调度.md
高频面试系列/座位调度.md
+4
-1
高频面试系列/打印素数.md
高频面试系列/打印素数.md
+40
-1
高频面试系列/接雨水.md
高频面试系列/接雨水.md
+4
-1
高频面试系列/最长回文子串.md
高频面试系列/最长回文子串.md
+5
-2
高频面试系列/水塘抽样.md
高频面试系列/水塘抽样.md
+4
-1
高频面试系列/消失的元素.md
高频面试系列/消失的元素.md
+4
-1
高频面试系列/缺失和重复的元素.md
高频面试系列/缺失和重复的元素.md
+4
-1
未找到文件。
动态规划系列/动态规划之KMP字符匹配算法.md
浏览文件 @
cfdfa288
...
...
@@ -428,5 +428,7 @@ KMP 算法也就是动态规划那点事,我们的公众号文章目录有一
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/动态规划之博弈问题.md
浏览文件 @
cfdfa288
...
...
@@ -212,5 +212,78 @@ int stoneGame(int[] piles) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
python3版本
由
[
SCUHZS
](
https://github.com/brucecat
)
提供
这里采取的是三维的做法
```
python
class
Solution
:
def
stoneGame
(
self
,
piles
:
List
[
int
])
->
bool
:
n
=
len
(
piles
)
# 初始化一个n*n的矩阵 dp数组
dp
=
[[
None
]
*
n
for
i
in
range
(
0
,
n
)]
# 在三角区域填充
for
i
in
range
(
n
):
for
j
in
range
(
i
,
n
):
dp
[
i
][
j
]
=
[
0
,
0
]
# 填入base case
for
i
in
range
(
0
,
n
):
dp
[
i
][
i
][
0
]
=
piles
[
i
]
dp
[
i
][
i
][
1
]
=
0
# 斜着遍历数组
for
l
in
range
(
2
,
n
+
1
):
for
i
in
range
(
0
,
n
-
l
+
1
):
j
=
l
+
i
-
1
# 先手选择最左边或最右边的分数
left
=
piles
[
i
]
+
dp
[
i
+
1
][
j
][
1
]
right
=
piles
[
j
]
+
dp
[
i
][
j
-
1
][
1
]
# 套用状态转移方程
if
left
>
right
:
dp
[
i
][
j
][
0
]
=
left
dp
[
i
][
j
][
1
]
=
dp
[
i
+
1
][
j
][
0
]
else
:
dp
[
i
][
j
][
0
]
=
right
dp
[
i
][
j
][
1
]
=
dp
[
i
][
j
-
1
][
0
]
res
=
dp
[
0
][
n
-
1
]
return
res
[
0
]
-
res
[
1
]
>
0
```
压缩成一维数组,以减小空间复杂度,做法如下。
```
python
class
Solution
:
def
stoneGame
(
self
,
piles
:
List
[
int
])
->
bool
:
dp
=
piles
.
copy
()
for
i
in
range
(
len
(
piles
)
-
1
,
-
1
,
-
1
):
# 从下往上遍历
for
j
in
range
(
i
,
len
(
piles
)):
# 从前往后遍历
dp
[
j
]
=
max
(
piles
[
i
]
-
dp
[
j
],
piles
[
j
]
-
dp
[
j
-
1
])
# 计算之后覆盖一维数组的对应位置
return
dp
[
len
(
piles
)
-
1
]
>
0
```
动态规划系列/动态规划之四键键盘.md
浏览文件 @
cfdfa288
...
...
@@ -197,5 +197,7 @@ def dp(n, a_num, copy):
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/动态规划之正则表达.md
浏览文件 @
cfdfa288
...
...
@@ -292,6 +292,7 @@ bool dp(string& s, int i, string& p, int j) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
动态规划系列/动态规划设计:最长递增子序列.md
浏览文件 @
cfdfa288
...
...
@@ -212,5 +212,7 @@ public int lengthOfLIS(int[] nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/动态规划详解进阶.md
浏览文件 @
cfdfa288
...
...
@@ -363,5 +363,7 @@ PS:为啥 `dp` 数组初始化为 `amount + 1` 呢,因为凑成 `amount` 金
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/团灭股票问题.md
浏览文件 @
cfdfa288
...
...
@@ -425,5 +425,7 @@ int maxProfit_k_any(int max_k, int[] prices) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/子序列问题模板.md
浏览文件 @
cfdfa288
# 动态规划之子序列问题解题模板
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -171,5 +171,7 @@ int longestPalindromeSubseq(string s) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,labuladong 带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/抢房子.md
浏览文件 @
cfdfa288
# 团灭 LeetCode 打家劫舍问题
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
<a href="https://www.zhihu.com/people/labuladong"><img src="https://img.shields.io/badge/%E7%9F%A5%E4%B9%8E-@labuladong-000000.svg?style=flat-square&logo=Zhihu"></a>
...
...
@@ -257,8 +255,10 @@ int[] dp(TreeNode root) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
[
Shantom
](
https://github.com/Shantom
)
提供 198. House Robber I Python3 解法代码:
```
Python
...
...
动态规划系列/最优子结构.md
浏览文件 @
cfdfa288
# 动态规划答疑篇
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -154,5 +154,7 @@ for (int i = 1; i < m; i++)
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/最长公共子序列.md
浏览文件 @
cfdfa288
...
...
@@ -144,5 +144,7 @@ else:
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/编辑距离.md
浏览文件 @
cfdfa288
...
...
@@ -288,5 +288,7 @@ class Node {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/贪心算法之区间调度问题.md
浏览文件 @
cfdfa288
...
...
@@ -155,5 +155,7 @@ int findMinArrowShots(int[][] intvs) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/高楼扔鸡蛋进阶.md
浏览文件 @
cfdfa288
...
...
@@ -292,5 +292,7 @@ while (lo < hi) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
动态规划系列/高楼扔鸡蛋问题.md
浏览文件 @
cfdfa288
# 经典动态规划问题:高楼扔鸡蛋
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -258,5 +258,7 @@ def superEggDrop(self, K: int, N: int) -> int:
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
技术/linuxshell.md
浏览文件 @
cfdfa288
...
...
@@ -154,5 +154,7 @@ $ sudo /home/fdl/bin/connect.sh
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
技术/linux进程.md
浏览文件 @
cfdfa288
...
...
@@ -138,5 +138,7 @@ $ cmd1 | cmd2 | cmd3
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
技术/redis入侵.md
浏览文件 @
cfdfa288
...
...
@@ -103,5 +103,7 @@ Redis 监听的默认端口是 6379,我们设置它接收网卡 127.0.0.1 的
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/table_qr2.jpg"
width=
500
>
</p>
\ No newline at end of file
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
技术/session和cookie.md
浏览文件 @
cfdfa288
...
...
@@ -152,5 +152,7 @@ https://github.com/astaxie/build-web-application-with-golang
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/table_qr2.jpg"
width=
500
>
</p>
\ No newline at end of file
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
技术/在线练习平台.md
浏览文件 @
cfdfa288
...
...
@@ -116,5 +116,7 @@ https://sqlzoo.net/
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/table_qr2.jpg"
width=
500
>
</p>
\ No newline at end of file
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
技术/密码技术.md
浏览文件 @
cfdfa288
...
...
@@ -199,7 +199,8 @@ HTTPS 协议中的 SSL/TLS 安全层会组合使用以上几种加密方式,**
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
[
test ad
](
https://labuladong.gitbook.io/algo
)
\ No newline at end of file
数据结构系列/二叉堆详解实现优先级队列.md
浏览文件 @
cfdfa288
...
...
@@ -236,5 +236,7 @@ public Key delMax() {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/二叉搜索树操作集锦.md
浏览文件 @
cfdfa288
...
...
@@ -307,5 +307,7 @@ void BST(TreeNode root, int target) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/单调栈.md
浏览文件 @
cfdfa288
...
...
@@ -178,5 +178,7 @@ vector<int> nextGreaterElements(vector<int>& nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/table_qr2.jpg"
width=
500
>
</p>
\ No newline at end of file
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/单调队列.md
浏览文件 @
cfdfa288
...
...
@@ -207,5 +207,7 @@ vector<int> maxSlidingWindow(vector<int>& nums, int k) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/实现计算器.md
浏览文件 @
cfdfa288
# 拆解复杂问题:实现计算器
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -303,5 +303,7 @@ def calculate(s: str) -> int:
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/设计Twitter.md
浏览文件 @
cfdfa288
...
...
@@ -299,5 +299,7 @@ PS:本文前两张图片和 GIF 是我第一次尝试用平板的绘图软件
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/递归反转链表的一部分.md
浏览文件 @
cfdfa288
...
...
@@ -215,5 +215,7 @@ ListNode reverseBetween(ListNode head, int m, int n) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
数据结构系列/队列实现栈栈实现队列.md
浏览文件 @
cfdfa288
...
...
@@ -227,5 +227,7 @@ public boolean empty() {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/FloodFill算法详解及应用.md
浏览文件 @
cfdfa288
...
...
@@ -236,5 +236,7 @@ int fill(int[][] image, int x, int y,
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/UnionFind算法应用.md
浏览文件 @
cfdfa288
...
...
@@ -247,5 +247,7 @@ boolean equationsPossible(String[] equations) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/UnionFind算法详解.md
浏览文件 @
cfdfa288
...
...
@@ -314,5 +314,7 @@ Union-Find 算法的复杂度可以这样分析:构造函数初始化数据结
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/twoSum问题的核心思想.md
浏览文件 @
cfdfa288
...
...
@@ -182,5 +182,7 @@ int[] twoSum(int[] nums, int target) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/为什么推荐算法4.md
浏览文件 @
cfdfa288
...
...
@@ -98,5 +98,7 @@
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/二分查找详解.md
浏览文件 @
cfdfa288
...
...
@@ -505,5 +505,7 @@ int right_bound(int[] nums, int target) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/信封嵌套问题.md
浏览文件 @
cfdfa288
...
...
@@ -132,5 +132,7 @@ public int lengthOfLIS(int[] nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/几个反直觉的概率问题.md
浏览文件 @
cfdfa288
...
...
@@ -138,5 +138,7 @@
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/前缀和技巧.md
浏览文件 @
cfdfa288
...
...
@@ -156,5 +156,7 @@ for (int i = 1; i < count.length; i++)
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/区间交集问题.md
浏览文件 @
cfdfa288
...
...
@@ -130,5 +130,7 @@ def intervalIntersection(A, B):
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/区间调度问题之区间合并.md
浏览文件 @
cfdfa288
...
...
@@ -88,5 +88,7 @@ def merge(intervals):
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/双指针技巧.md
浏览文件 @
cfdfa288
...
...
@@ -227,5 +227,7 @@ void reverse(int[] nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/回溯算法详解修订版.md
浏览文件 @
cfdfa288
...
...
@@ -306,5 +306,7 @@ def backtrack(...):
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/字符串乘法.md
浏览文件 @
cfdfa288
...
...
@@ -98,5 +98,7 @@ string multiply(string num1, string num2) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/table_qr2.jpg"
width=
500
>
</p>
\ No newline at end of file
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/学习数据结构和算法的高效方法.md
浏览文件 @
cfdfa288
...
...
@@ -306,5 +306,7 @@ N 叉树的遍历框架,找出来了把~你说,树这种结构重不重要
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/常用的位操作.md
浏览文件 @
cfdfa288
...
...
@@ -169,5 +169,7 @@ http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/洗牌算法.md
浏览文件 @
cfdfa288
...
...
@@ -208,5 +208,7 @@ for (int feq : count)
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/滑动窗口技巧.md
浏览文件 @
cfdfa288
# 滑动窗口技巧
# 滑动窗口算法框架
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
<a href="https://www.zhihu.com/people/labuladong"><img src="https://img.shields.io/badge/%E7%9F%A5%E4%B9%8E-@labuladong-000000.svg?style=flat-square&logo=Zhihu"></a>
<a href="https://i.loli.net/2020/10/10/MhRTyUKfXZOlQYN.jpg"><img src="https://img.shields.io/badge/公众号-@labuladong-000000.svg?style=flat-square&logo=WeChat"></a>
<a href="https://space.bilibili.com/14089380"><img src="https://img.shields.io/badge/B站-@labuladong-000000.svg?style=flat-square&logo=Bilibili"></a>
</p>
![](
../pictures/souyisou.png
)
**最新消息:关注公众号参与活动,有机会成为 [70k star 算法仓库](https://github.com/labuladong/fucking-algorithm) 的贡献者,机不可失时不再来**
!
相关推荐:
*
[
东哥吃葡萄时竟然吃出一道算法题!
](
../高频面试系列/吃葡萄.md
)
*
[
如何寻找缺失的元素
](
../高频面试系列/消失的元素.md
)
读完本文,你不仅学会了算法套路,还可以顺便去 LeetCode 上拿下如下题目:
[
76.最小覆盖子串
](
https://leetcode-cn.com/problems/minimum-window-substring
)
[
567.字符串的排列
](
https://leetcode-cn.com/problems/permutation-in-string
)
[
438.找到字符串中所有字母异位词
](
https://leetcode-cn.com/problems/find-all-anagrams-in-a-string
)
[
3.无重复字符的最长子串
](
https://leetcode-cn.com/problems/longest-substring-without-repeating-characters
)
**-----------**
本文详解「滑动窗口」这种高级双指针技巧的算法框架,带你秒杀几道高难度的子字符串匹配问题。
...
...
@@ -334,8 +361,14 @@ class Solution:
return s[start:start+min_len] if min_len != float("Inf") else ""
```
[
上一篇:二分查找解题框架
](
https://labuladong.gitbook.io/algo
)
**_____________**
**刷算法,学套路,认准 labuladong,公众号和 [在线电子书](https://labuladong.gitbook.io/algo) 持续更新最新文章**
。
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
[
下一篇:双指针技巧解题框架
](
https://labuladong.gitbook.io/algo
)
<p
align=
'center'
>
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
[
目录
](
https://labuladong.gitbook.io/algo#目录
)
======其他语言代码======
\ No newline at end of file
算法思维系列/烧饼排序.md
浏览文件 @
cfdfa288
...
...
@@ -146,5 +146,7 @@ void reverse(int[] arr, int i, int j) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/算法学习之路.md
浏览文件 @
cfdfa288
...
...
@@ -101,5 +101,7 @@ PS:**如果有的英文题目实在看不懂,有个小技巧**,你在题
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
算法思维系列/递归详解.md
浏览文件 @
cfdfa288
...
...
@@ -272,5 +272,7 @@ https://leetcode.com/tag/divide-and-conquer/
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/LRU算法.md
浏览文件 @
cfdfa288
...
...
@@ -343,5 +343,7 @@ class LRUCache {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/koko偷香蕉.md
浏览文件 @
cfdfa288
...
...
@@ -166,5 +166,7 @@ for (int i = 0; i < n; i++)
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/k个一组反转链表.md
浏览文件 @
cfdfa288
...
...
@@ -153,5 +153,7 @@ ListNode reverseKGroup(ListNode head, int k) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/一行代码解决的智力题.md
浏览文件 @
cfdfa288
...
...
@@ -146,5 +146,7 @@ int bulbSwitch(int n) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/二分查找判定子序列.md
浏览文件 @
cfdfa288
...
...
@@ -165,5 +165,7 @@ boolean isSubsequence(String s, String t) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/判断回文链表.md
浏览文件 @
cfdfa288
...
...
@@ -234,5 +234,7 @@ p.next = reverse(q);
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/合法括号判定.md
浏览文件 @
cfdfa288
...
...
@@ -109,5 +109,7 @@ char leftOf(char c) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/如何去除有序数组的重复元素.md
浏览文件 @
cfdfa288
...
...
@@ -108,8 +108,14 @@ def deleteDuplicates(self, head: ListNode) -> ListNode:
return
head
```
[
上一篇:如何高效解决接雨水问题
](
https://labuladong.gitbook.io/algo
)
**_____________**
[
下一篇:如何寻找最长回文子串
](
https://labuladong.gitbook.io/algo
)
**刷算法,学套路,认准 labuladong,公众号和 [在线电子书](https://labuladong.gitbook.io/algo) 持续更新最新文章**
。
[
目录
](
https://labuladong.gitbook.io/algo#目录
)
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/子集排列组合.md
浏览文件 @
cfdfa288
# 回溯算法团灭子集、排列、组合问题
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -281,5 +281,7 @@ void backtrack(int[] nums, LinkedList<Integer> track) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/座位调度.md
浏览文件 @
cfdfa288
...
...
@@ -230,5 +230,7 @@ private int distance(int[] intv) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/打印素数.md
浏览文件 @
cfdfa288
...
...
@@ -175,5 +175,44 @@ int countPrimes(int n) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
C++解法:
采用的算法是埃拉托斯特尼筛法
埃拉托斯特尼筛法的具体内容就是:
**要得到自然数n以内的全部素数,必须把不大于根号n的所有素数的倍数剔除,剩下的就是素数。**
同时考虑到大于2的偶数都不是素数,所以可以进一步优化成:
**要得到自然数n以内的全部素数,必须把不大于根号n的所有素数的奇数倍剔除,剩下的奇数就是素数。**
此算法其实就是上面的Java解法所采用的。
这里提供C++的代码:
```
C++
class Solution {
public:
int countPrimes(int n) {
int res = 0;
bool prime[n+1];
for(int i = 0; i < n; ++i)
prime[i] = true;
for(int i = 2; i <= sqrt(n); ++i) //计数过程
{ //外循环优化,因为判断一个数是否为质数只需要整除到sqrt(n),反推亦然
if(prime[i])
{
for(int j = i * i; j < n; j += i) //内循环优化,i*i之前的比如i*2,i*3等,在之前的循环中已经验证了
{
prime[j] = false;
}
}
}
for (int i = 2; i < n; ++i)
if (prime[i]) res++; //最后遍历统计一遍,存入res
return res;
}
};
```
高频面试系列/接雨水.md
浏览文件 @
cfdfa288
...
...
@@ -208,5 +208,7 @@ if (l_max < r_max) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/最长回文子串.md
浏览文件 @
cfdfa288
# 如何寻找最长回文子串
**学好算法全靠套路,认准 labuladong 就够了**
。
<p
align=
'center'
>
<a
href=
"https://github.com/labuladong/fucking-algorithm"
target=
"view_window"
><img
alt=
"GitHub"
src=
"https://img.shields.io/github/stars/labuladong/fucking-algorithm?label=Stars&style=flat-square&logo=GitHub"
></a>
...
...
@@ -128,5 +128,7 @@ string longestPalindrome(string s) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/水塘抽样.md
浏览文件 @
cfdfa288
...
...
@@ -145,5 +145,7 @@ $$ -->
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/消失的元素.md
浏览文件 @
cfdfa288
...
...
@@ -129,5 +129,7 @@ public int missingNumber(int[] nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
高频面试系列/缺失和重复的元素.md
浏览文件 @
cfdfa288
...
...
@@ -136,5 +136,7 @@ vector<int> findErrorNums(vector<int>& nums) {
**本小抄即将出版,微信扫码关注公众号,后台回复「小抄」限时免费获取,回复「进群」可进刷题群一起刷题,带你搞定 LeetCode**
。
<p
align=
'center'
>
<img
src=
"../pictures/
table_qr2.jpg"
width=
5
00
>
<img
src=
"../pictures/
qrcode.jpg"
width=
2
00
>
</p>
======其他语言代码======
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录