Skip to content

Commit 86a0208

Browse files
替换图片链接
1 parent 91e7dab commit 86a0208

File tree

216 files changed

+813
-813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+813
-813
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181

182182

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

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

223223
题目分类大纲如下:
224224

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

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

254254

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

257257
1. [关于贪心算法,你该了解这些!](./problems/贪心算法理论基础.md)
258258
2. [贪心算法:455.分发饼干](./problems/0455.分发饼干.md)
@@ -503,5 +503,5 @@
503503

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

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

problems/0001.两数之和.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ map目的用来存放我们访问过的元素,因为遍历数组的时候,
8383

8484
过程如下:
8585

86-
![过程一](https://code-thinking-1253855093.file.myqcloud.com/pics/20220711202638.png)
86+
![过程一](https://file.kamacoder.com/pics/20220711202638.png)
8787

8888

89-
![过程二](https://code-thinking-1253855093.file.myqcloud.com/pics/20230220223536.png)
89+
![过程二](https://file.kamacoder.com/pics/20230220223536.png)
9090

9191
C++代码:
9292

problems/0005.最长回文子串.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ dp[i][j]可以初始化为true么? 当然不行,怎能刚开始就全都匹
106106

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

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

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

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

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

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

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

problems/0017.电话号码的字母组合.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

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

1616
示例:
1717
* 输入:"23"
@@ -64,7 +64,7 @@ const string letterMap[10] = {
6464

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

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

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

problems/0019.删除链表的倒数第N个节点.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
示例 1:
1717

1818

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

2121
输入:head = [1,2,3,4,5], n = 2
2222
输出:[1,2,3,5]

problems/0020.有效的括号.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ cd a/b/c/../../
8181

8282

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

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

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

9292

9393

problems/0035.搜索插入位置.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
这道题目,要在数组中插入目标值,无非是这四种情况。
4343

44-
![35_搜索插入位置3](https://code-thinking-1253855093.file.myqcloud.com/pics/20201216232148471.png)
44+
![35_搜索插入位置3](https://file.kamacoder.com/pics/20201216232148471.png)
4545

4646
* 目标值在数组所有元素之前
4747
* 目标值等于数组中某一个元素
@@ -82,14 +82,14 @@ public:
8282
8383
效率如下:
8484
85-
![35_搜索插入位置](https://code-thinking-1253855093.file.myqcloud.com/pics/20201216232127268.png)
85+
![35_搜索插入位置](https://file.kamacoder.com/pics/20201216232127268.png)
8686
8787
### 二分法
8888
8989
既然暴力解法的时间复杂度是O(n),就要尝试一下使用二分查找法。
9090
9191
92-
![35_搜索插入位置4](https://code-thinking-1253855093.file.myqcloud.com/pics/202012162326354.png)
92+
![35_搜索插入位置4](https://file.kamacoder.com/pics/202012162326354.png)
9393
9494
大家注意这道题目的前提是数组是有序数组,这也是使用二分查找的基础条件。
9595
@@ -99,7 +99,7 @@ public:
9999
100100
大体讲解一下二分法的思路,这里来举一个例子,例如在这个数组中,使用二分法寻找元素为5的位置,并返回其下标。
101101
102-
![35_搜索插入位置5](https://code-thinking-1253855093.file.myqcloud.com/pics/20201216232659199.png)
102+
![35_搜索插入位置5](https://file.kamacoder.com/pics/20201216232659199.png)
103103
104104
二分查找涉及的很多的边界条件,逻辑比较简单,就是写不好。
105105
@@ -150,7 +150,7 @@ public:
150150
* 空间复杂度:O(1)
151151

152152
效率如下:
153-
![35_搜索插入位置2](https://code-thinking-1253855093.file.myqcloud.com/pics/2020121623272877.png)
153+
![35_搜索插入位置2](https://file.kamacoder.com/pics/2020121623272877.png)
154154

155155
### 二分法第二种写法
156156

problems/0037.解数独.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。
1919
空白格用 '.' 表示。
2020

21-
![解数独](https://code-thinking-1253855093.file.myqcloud.com/pics/202011171912586.png)
21+
![解数独](https://file.kamacoder.com/pics/202011171912586.png)
2222

2323
一个数独。
2424

25-
![解数独](https://code-thinking-1253855093.file.myqcloud.com/pics/20201117191340669.png)
25+
![解数独](https://file.kamacoder.com/pics/20201117191340669.png)
2626

2727
答案被标成红色。
2828

@@ -52,7 +52,7 @@
5252

5353
因为这个树形结构太大了,我抽取一部分,如图所示:
5454

55-
![37.解数独](https://code-thinking-1253855093.file.myqcloud.com/pics/2020111720451790-20230310131816104.png)
55+
![37.解数独](https://file.kamacoder.com/pics/2020111720451790-20230310131816104.png)
5656

5757

5858
### 回溯三部曲
@@ -83,7 +83,7 @@ bool backtracking(vector<vector<char>>& board)
8383
8484
* 递归单层搜索逻辑
8585
86-
![37.解数独](https://code-thinking-1253855093.file.myqcloud.com/pics/2020111720451790-20230310131822254.png)
86+
![37.解数独](https://file.kamacoder.com/pics/2020111720451790-20230310131822254.png)
8787
8888
在树形图中可以看出我们需要的是一个二维的递归 (一行一列)
8989

problems/0039.组合总和.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ candidates 中的数字可以无限制重复被选取。
5050

5151
本题搜索的过程抽象成树形结构如下:
5252

53-
![39.组合总和](https://code-thinking-1253855093.file.myqcloud.com/pics/20201223170730367.png)
53+
![39.组合总和](https://file.kamacoder.com/pics/20201223170730367.png)
5454
注意图中叶子节点的返回条件,因为本题没有组合数量要求,仅仅是总和的限制,所以递归没有层数的限制,只要选取的元素总和超过target,就返回!
5555

5656
而在[77.组合](https://programmercarl.com/0077.组合.html)[216.组合总和III](https://programmercarl.com/0216.组合总和III.html) 中都可以知道要递归K层,因为要取k个元素的组合。
@@ -85,7 +85,7 @@ void backtracking(vector<int>& candidates, int target, int sum, int startIndex)
8585
8686
在如下树形结构中:
8787
88-
![39.组合总和](https://code-thinking-1253855093.file.myqcloud.com/pics/20201223170730367-20230310135337214.png)
88+
![39.组合总和](https://file.kamacoder.com/pics/20201223170730367-20230310135337214.png)
8989
9090
从叶子节点可以清晰看到,终止只有两种情况,sum大于target和sum等于target。
9191
@@ -158,7 +158,7 @@ public:
158158
159159
在这个树形结构中:
160160
161-
![39.组合总和](https://code-thinking-1253855093.file.myqcloud.com/pics/20201223170730367-20230310135342472.png)
161+
![39.组合总和](https://file.kamacoder.com/pics/20201223170730367-20230310135342472.png)
162162
163163
以及上面的版本一的代码大家可以看到,对于sum已经大于target的情况,其实是依然进入了下一层递归,只是下一层递归结束判断的时候,会判断sum > target的话就返回。
164164
@@ -171,7 +171,7 @@ public:
171171
如图:
172172
173173
174-
![39.组合总和1](https://code-thinking-1253855093.file.myqcloud.com/pics/20201223170809182.png)
174+
![39.组合总和1](https://file.kamacoder.com/pics/20201223170809182.png)
175175
176176
for循环剪枝代码如下:
177177

problems/0040.组合总和II.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ candidates 中的每个数字在每个组合中只能使用一次。
7676

7777
选择过程树形结构如图所示:
7878

79-
![40.组合总和II](https://code-thinking-1253855093.file.myqcloud.com/pics/20230310000918.png)
79+
![40.组合总和II](https://file.kamacoder.com/pics/20230310000918.png)
8080

8181
可以看到图中,每个节点相对于 [39.组合总和](https://mp.weixin.qq.com/s/FLg8G6EjVcxBjwCbzpACPw)我多加了used数组,这个used数组下面会重点介绍。
8282

@@ -126,7 +126,7 @@ if (sum == target) {
126126

127127
这块比较抽象,如图:
128128

129-
![40.组合总和II1](https://code-thinking-1253855093.file.myqcloud.com/pics/20230310000954.png)
129+
![40.组合总和II1](https://file.kamacoder.com/pics/20230310000954.png)
130130

131131
我在图中将used的变化用橘黄色标注上,可以看出在candidates[i] == candidates[i - 1]相同的情况下:
132132

@@ -137,7 +137,7 @@ if (sum == target) {
137137

138138
而 used[i - 1] == true,说明是进入下一层递归,去下一个数,所以是树枝上,如图所示:
139139

140-
![](https://code-thinking-1253855093.file.myqcloud.com/pics/20221021163812.png)
140+
![](https://file.kamacoder.com/pics/20221021163812.png)
141141

142142

143143
**这块去重的逻辑很抽象,网上搜的题解基本没有能讲清楚的,如果大家之前思考过这个问题或者刷过这道题目,看到这里一定会感觉通透了很多!**

0 commit comments

Comments
 (0)