Skip to content

[pull] master from youngyangyang04:master #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
  •  
  •  
  •  
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@

## 前序

* [「代码随想录」学习社区](https://programmercarl.com/other/kstar.html)
* [做项目(多个C++、Java、Go、前端、测开项目)](https://programmercarl.com/other/kstar.html)


* 编程语言
* [C++面试&C++学习指南知识点整理](https://github.com/youngyangyang04/TechCPP)
* [编程语言基础课](https://kamacoder.com/courseshop.php)
* [23种设计模式](https://github.com/youngyangyang04/kama-DesignPattern)
* [大厂算法笔试题](https://kamacoder.com/company.php)

* 工具
* [一站式vim配置](https://github.com/youngyangyang04/PowerVim)
Expand Down Expand Up @@ -180,7 +181,7 @@


题目分类大纲如下:
<img src='https://code-thinking-1253855093.file.myqcloud.com/pics/20240424172231.png' width=600 alt='二叉树大纲'> </img></div>
<img src='https://file1.kamacoder.com/i/algo/20240424172231.png' width=600 alt='二叉树大纲'> </img></div>

1. [关于二叉树,你该了解这些!](./problems/二叉树理论基础.md)
2. [二叉树:二叉树的递归遍历](./problems/二叉树的递归遍历.md)
Expand Down Expand Up @@ -221,7 +222,7 @@

题目分类大纲如下:

<img src='https://code-thinking-1253855093.file.myqcloud.com/pics/20240424172311.png' width=600 alt='回溯算法大纲'> </img></div>
<img src='https://file1.kamacoder.com/i/algo/20240424172311.png' width=600 alt='回溯算法大纲'> </img></div>

1. [关于回溯算法,你该了解这些!](./problems/回溯算法理论基础.md)
2. [回溯算法:77.组合](./problems/0077.组合.md)
Expand Down Expand Up @@ -251,7 +252,7 @@
题目分类大纲如下:


<img src='https://code-thinking-1253855093.file.myqcloud.com/pics/20210917104315.png' width=600 alt='贪心算法大纲'> </img></div>
<img src='https://file1.kamacoder.com/i/algo/20210917104315.png' width=600 alt='贪心算法大纲'> </img></div>

1. [关于贪心算法,你该了解这些!](./problems/贪心算法理论基础.md)
2. [贪心算法:455.分发饼干](./problems/0455.分发饼干.md)
Expand Down Expand Up @@ -282,7 +283,7 @@

动态规划专题已经开始啦,来不及解释了,小伙伴们上车别掉队!

<img src='https://code-thinking.cdn.bcebos.com/pics/动态规划-总结大纲1.jpg' width=500> </img></div>
<img src='https://file1.kamacoder.com/i/algo/动态规划-总结大纲1.jpg' width=500> </img></div>
1. [关于动态规划,你该了解这些!](./problems/动态规划理论基础.md)
2. [动态规划:509.斐波那契数](./problems/0509.斐波那契数.md)
3. [动态规划:70.爬楼梯](./problems/0070.爬楼梯.md)
Expand All @@ -296,7 +297,7 @@

背包问题系列:

<img src='https://code-thinking.cdn.bcebos.com/pics/动态规划-背包问题总结.png' width=500 alt='背包问题大纲'> </img></div>
<img src='https://file1.kamacoder.com/i/algo/动态规划-背包问题总结.png' width=500 alt='背包问题大纲'> </img></div>


11. [动态规划:01背包理论基础(二维dp数组)](./problems/背包理论基础01背包-1.md)
Expand Down Expand Up @@ -327,7 +328,7 @@

股票系列:

<img src='https://code-thinking.cdn.bcebos.com/pics/股票问题总结.jpg' width=500 alt='股票问题总结'> </img></div>
<img src='https://file1.kamacoder.com/i/algo/股票问题总结.jpg' width=500 alt='股票问题总结'> </img></div>


32. [动态规划:121.买卖股票的最佳时机](./problems/0121.买卖股票的最佳时机.md)
Expand All @@ -342,7 +343,7 @@

子序列系列:

<img src='https://code-thinking.cdn.bcebos.com/pics/动态规划-子序列问题总结.jpg' width=500 alt=''> </img></div>
<img src='https://file1.kamacoder.com/i/algo/动态规划-子序列问题总结.jpg' width=500 alt=''> </img></div>


41. [动态规划:300.最长递增子序列](./problems/0300.最长上升子序列.md)
Expand Down Expand Up @@ -385,9 +386,9 @@
9. [图论:沉没孤岛](./problems/kamacoder/0102.沉没孤岛.md)
10. [图论:水流问题](./problems/kamacoder/0103.水流问题.md)
11. [图论:建造最大岛屿](./problems/kamacoder/0104.建造最大岛屿.md)
12. [图论:字符串接龙](./problems/kamacoder/0110.字符串接龙.md)
13. [图论:有向图的完全可达性](./problems/kamacoder/0105.有向图的完全可达性.md)
14. [图论:岛屿的周长](./problems/kamacoder/0106.岛屿的周长.md)
12. [图论:岛屿的周长](./problems/kamacoder/0106.岛屿的周长.md)
13. [图论:字符串接龙](./problems/kamacoder/0110.字符串接龙.md)
14. [图论:有向图的完全可达性](./problems/kamacoder/0105.有向图的完全可达性.md)
15. [图论:并查集理论基础](./problems/kamacoder/图论并查集理论基础.md)
16. [图论:寻找存在的路径](./problems/kamacoder/0107.寻找存在的路径.md)
17. [图论:冗余连接](./problems/kamacoder/0108.冗余连接.md)
Expand Down Expand Up @@ -502,5 +503,5 @@

添加微信记得备注,如果是已工作,备注:姓名-城市-岗位。如果学生,备注:姓名-学校-年级。**备注没有自我介绍不通过哦**

<div align="center"><img src="https://code-thinking-1253855093.file.myqcloud.com/pics/第二企业刷题活码.png" data-img="1" width="200" height="200"></img></div>
<div align="center"><img src="https://file1.kamacoder.com/i/algo/shuati20250519.jpg" data-img="1" width="200" height="200"></img></div>

16 changes: 5 additions & 11 deletions problems/0001.两数之和.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)


# 1. 两数之和
Expand Down Expand Up @@ -85,10 +83,10 @@ map目的用来存放我们访问过的元素,因为遍历数组的时候,

过程如下:

![过程一](https://code-thinking-1253855093.file.myqcloud.com/pics/20220711202638.png)
![过程一](https://file1.kamacoder.com/i/algo/20220711202638.png)


![过程二](https://code-thinking-1253855093.file.myqcloud.com/pics/20230220223536.png)
![过程二](https://file1.kamacoder.com/i/algo/20230220223536.png)

C++代码:

Expand Down Expand Up @@ -557,7 +555,3 @@ int* twoSum(int* nums, int numsSize, int target, int* returnSize){
}
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>
16 changes: 5 additions & 11 deletions problems/0005.最长回文子串.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)



Expand Down Expand Up @@ -108,7 +106,7 @@ dp[i][j]可以初始化为true么? 当然不行,怎能刚开始就全都匹

dp[i + 1][j - 1] 在 dp[i][j]的左下角,如图:

![647.回文子串](https://code-thinking-1253855093.file.myqcloud.com/pics/20210121171032473.jpg)
![647.回文子串](https://file1.kamacoder.com/i/algo/20210121171032473.jpg)

如果这矩阵是从上到下,从左到右遍历,那么会用到没有计算过的dp[i + 1][j - 1],也就是根据不确定是不是回文的区间[i+1,j-1],来判断了[i,j]是不是回文,那结果一定是不对的。

Expand Down Expand Up @@ -142,7 +140,7 @@ for (int i = s.size() - 1; i >= 0; i--) { // 注意遍历顺序

举例,输入:"aaa",dp[i][j]状态如下:

![647.回文子串1](https://code-thinking-1253855093.file.myqcloud.com/pics/20210121171059951.jpg)
![647.回文子串1](https://file1.kamacoder.com/i/algo/20210121171059951.jpg)

**注意因为dp[i][j]的定义,所以j一定是大于等于i的,那么在填充dp[i][j]的时候一定是只填充右上半部分**。

Expand Down Expand Up @@ -731,8 +729,4 @@ public class Solution {
```


<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

14 changes: 4 additions & 10 deletions problems/0015.三数之和.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)



Expand Down Expand Up @@ -102,7 +100,7 @@ public:

动画效果如下:

![15.三数之和](https://code-thinking.cdn.bcebos.com/gifs/15.%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.gif)
![15.三数之和](https://file1.kamacoder.com/i/algo/15.%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.gif)

拿这个nums数组来举例,首先将数组排序,然后有一层for循环,i从下标0的地方开始,同时定一个下标left 定义在i+1的位置上,定义下标right 在数组结尾的位置上。

Expand Down Expand Up @@ -980,7 +978,3 @@ object Solution {
}
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>
16 changes: 5 additions & 11 deletions problems/0017.电话号码的字母组合.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)


# 17.电话号码的字母组合
Expand All @@ -13,7 +11,7 @@

给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。

![17.电话号码的字母组合](https://code-thinking-1253855093.file.myqcloud.com/pics/2020102916424043.png)
![17.电话号码的字母组合](https://file1.kamacoder.com/i/algo/2020102916424043.png)

示例:
* 输入:"23"
Expand Down Expand Up @@ -66,7 +64,7 @@ const string letterMap[10] = {

例如:输入:"23",抽象为树形结构,如图所示:

![17. 电话号码的字母组合](https://code-thinking-1253855093.file.myqcloud.com/pics/20201123200304469.png)
![17. 电话号码的字母组合](https://file1.kamacoder.com/i/algo/20201123200304469.png)

图中可以看出遍历的深度,就是输入"23"的长度,而叶子节点就是我们要收集的结果,输出["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]。

Expand Down Expand Up @@ -766,7 +764,3 @@ public class Solution
```


<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>
12 changes: 3 additions & 9 deletions problems/0018.四数之和.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)


> 一样的道理,能解决四数之和
Expand Down Expand Up @@ -798,8 +796,4 @@ def four_sum(nums, target)
end
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

22 changes: 8 additions & 14 deletions problems/0019.删除链表的倒数第N个节点.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)



Expand All @@ -18,7 +16,7 @@
示例 1:


![19.删除链表的倒数第N个节点](https://code-thinking-1253855093.file.myqcloud.com/pics/20210510085957392.png)
![19.删除链表的倒数第N个节点](https://file1.kamacoder.com/i/algo/20210510085957392.png)

输入:head = [1,2,3,4,5], n = 2
输出:[1,2,3,5]
Expand Down Expand Up @@ -51,16 +49,16 @@

* 定义fast指针和slow指针,初始值为虚拟头结点,如图:

<img src='https://code-thinking.cdn.bcebos.com/pics/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B9.png' width=600> </img></div>
<img src='https://file1.kamacoder.com/i/algo/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B9.png' width=600> </img></div>

* fast首先走n + 1步 ,为什么是n+1呢,因为只有这样同时移动的时候slow才能指向删除节点的上一个节点(方便做删除操作),如图:
<img src='https://code-thinking.cdn.bcebos.com/pics/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B91.png' width=600> </img></div>
<img src='https://file1.kamacoder.com/i/algo/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B91.png' width=600> </img></div>

* fast和slow同时移动,直到fast指向末尾,如题:
<img src='https://code-thinking.cdn.bcebos.com/pics/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B92.png' width=600> </img></div>
<img src='https://file1.kamacoder.com/i/algo/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B92.png' width=600> </img></div>
//图片中有错别词:应该将“只到”改为“直到”
* 删除slow指向的下一个节点,如图:
<img src='https://code-thinking.cdn.bcebos.com/pics/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B93.png' width=600> </img></div>
<img src='https://file1.kamacoder.com/i/algo/19.%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%ACN%E4%B8%AA%E8%8A%82%E7%82%B93.png' width=600> </img></div>

此时不难写出如下C++代码:

Expand Down Expand Up @@ -479,7 +477,3 @@ public class Solution {
}
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>
20 changes: 7 additions & 13 deletions problems/0020.有效的括号.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p align="center">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)



Expand Down Expand Up @@ -83,21 +81,21 @@ cd a/b/c/../../


1. 第一种情况,字符串里左方向的括号多余了 ,所以不匹配。
![括号匹配1](https://code-thinking-1253855093.file.myqcloud.com/pics/2020080915505387.png)
![括号匹配1](https://file1.kamacoder.com/i/algo/2020080915505387.png)

2. 第二种情况,括号没有多余,但是 括号的类型没有匹配上。
![括号匹配2](https://code-thinking-1253855093.file.myqcloud.com/pics/20200809155107397.png)
![括号匹配2](https://file1.kamacoder.com/i/algo/20200809155107397.png)

3. 第三种情况,字符串里右方向的括号多余了,所以不匹配。
![括号匹配3](https://code-thinking-1253855093.file.myqcloud.com/pics/20200809155115779.png)
![括号匹配3](https://file1.kamacoder.com/i/algo/20200809155115779.png)



我们的代码只要覆盖了这三种不匹配的情况,就不会出问题,可以看出 动手之前分析好题目的重要性。

动画如下:

![20.有效括号](https://code-thinking.cdn.bcebos.com/gifs/20.有效括号.gif)
![20.有效括号](https://file1.kamacoder.com/i/algo/20.有效括号.gif)


第一种情况:已经遍历完了字符串,但是栈不为空,说明有相应的左括号没有右括号来匹配,所以return false
Expand Down Expand Up @@ -574,8 +572,4 @@ impl Solution {
}
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

Loading