Skip to content

Commit 49d45cf

Browse files
Update
1 parent 9be2398 commit 49d45cf

8 files changed

+56
-54
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@
305305

306306
背包问题系列:
307307

308-
<img src='https://img-blog.csdnimg.cn/202102261550480.png' width=500 alt='背包问题大纲'> </img></div>
308+
<img src='https://code-thinking.cdn.bcebos.com/pics/动态规划-背包问题总结.png' width=500 alt='背包问题大纲'> </img></div>
309+
309310

310311
11. [动态规划:关于01背包问题,你该了解这些!](./problems/背包理论基础01背包-1.md)
311312
12. [动态规划:关于01背包问题,你该了解这些!(滚动数组)](./problems/背包理论基础01背包-2.md)
@@ -334,7 +335,8 @@
334335

335336
股票系列:
336337

337-
<img src='https://code-thinking.cdn.bcebos.com/pics/%E8%82%A1%E7%A5%A8%E9%97%AE%E9%A2%98%E6%80%BB%E7%BB%93.jpg' width=500 alt='股票问题总结'> </img></div>
338+
<img src='https://code-thinking.cdn.bcebos.com/pics/股票问题总结.jpg' width=500 alt='股票问题总结'> </img></div>
339+
338340

339341
32. [动态规划:买卖股票的最佳时机](./problems/0121.买卖股票的最佳时机.md)
340342
33. [动态规划:本周我们都讲了这些(系列六)](./problems/周总结/20210225动规周末总结.md)
@@ -348,6 +350,9 @@
348350

349351
子序列系列:
350352

353+
<img src='https://code-thinking.cdn.bcebos.com/pics/动态规划-子序列问题总结.jpg' width=500 alt=''> </img></div>
354+
355+
351356
40. [动态规划:最长递增子序列](./problems/0300.最长上升子序列.md)
352357
41. [动态规划:最长连续递增序列](./problems/0674.最长连续递增序列.md)
353358
42. [动态规划:最长重复子数组](./problems/0718.最长重复子数组.md)

problems/0001.两数之和.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ std::unordered_map 底层实现为哈希表,std::map 和std::multimap 的底
5757

5858
解题思路动画如下:
5959

60-
<video src='https://code-thinking.cdn.bcebos.com/gifs/1.%E4%B8%A4%E6%95%B0%E4%B9%8B%E5%92%8C.mp4' controls='controls' width='640' height='320' autoplay='autoplay'> Your browser does not support the video tag.</video></div>
60+
![](https://code-thinking.cdn.bcebos.com/gifs/1.两数之和.mp4)
6161

6262
C++代码:
6363

problems/0202.快乐数.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ https://leetcode-cn.com/problems/happy-number/
2222

2323
**示例:**
2424

25-
输入:19
26-
输出:true
27-
解释:
28-
1^2 + 9^2 = 82
29-
8^2 + 2^2 = 68
30-
6^2 + 8^2 = 100
31-
1^2 + 0^2 + 0^2 = 1
25+
输入:19
26+
输出:true
27+
解释:
28+
1^2 + 9^2 = 82
29+
8^2 + 2^2 = 68
30+
6^2 + 8^2 = 100
31+
1^2 + 0^2 + 0^2 = 1
3232

3333
# 思路
3434

3535
这道题目看上去貌似一道数学问题,其实并不是!
3636

3737
题目中说了会 **无限循环**,那么也就是说**求和的过程中,sum会重复出现,这对解题很重要!**
3838

39-
正如:[关于哈希表,你该了解这些!](https://mp.weixin.qq.com/s/g8N6WmoQmsCUw3_BaWxHZA)中所说,**当我们遇到了要快速判断一个元素是否出现集合里的时候,就要考虑哈希法了。**
39+
正如:[关于哈希表,你该了解这些!](https://mp.weixin.qq.com/s/RSUANESA_tkhKhYe3ZR8Jg)中所说,**当我们遇到了要快速判断一个元素是否出现集合里的时候,就要考虑哈希法了。**
4040

4141
所以这道题目使用哈希法,来判断这个sum是否重复出现,如果重复了就是return false, 否则一直找到sum为1为止。
4242

@@ -80,7 +80,7 @@ public:
8080
8181
8282
83-
## 其他语言版本
83+
# 其他语言版本
8484
8585
8686
Java:

problems/0203.移除链表元素.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ https://leetcode-cn.com/problems/remove-linked-list-elements/
1515

1616
题意:删除链表中等于给定值 val 的所有节点。
1717

18-
![203题目示例](https://img-blog.csdnimg.cn/20200814104441179.png)
18+
示例 1:
19+
输入:head = [1,2,6,3,4,5,6], val = 6
20+
输出:[1,2,3,4,5]
21+
22+
示例 2:
23+
输入:head = [], val = 1
24+
输出:[]
25+
26+
示例 3:
27+
输入:head = [7,7,7,7], val = 7
28+
输出:[]
29+
1930

2031
# 思路
2132

problems/0209.长度最小的子数组.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,6 @@ public:
116116

117117
不要以为for里放一个while就以为是$O(n^2)$啊, 主要是看每一个元素被操作的次数,每个元素在滑动窗后进来操作一次,出去操作一次,每个元素都是被被操作两次,所以时间复杂度是2 * n 也就是$O(n)$。
118118

119-
## 其他语言补充
120-
121-
python:
122-
123-
```python
124-
class Solution:
125-
def minSubArrayLen(self, s: int, nums: List[int]) -> int:
126-
# 定义一个无限大的数
127-
res = float("inf")
128-
Sum = 0
129-
index = 0
130-
for i in range(len(nums)):
131-
Sum += nums[i]
132-
while Sum >= s:
133-
res = min(res, i-index+1)
134-
Sum -= nums[index]
135-
index += 1
136-
return 0 if res==float("inf") else res
137-
```
138-
139119
## 相关题目推荐
140120

141121
* 904.水果成篮
@@ -170,6 +150,22 @@ class Solution {
170150

171151
Python:
172152

153+
```python
154+
class Solution:
155+
def minSubArrayLen(self, s: int, nums: List[int]) -> int:
156+
# 定义一个无限大的数
157+
res = float("inf")
158+
Sum = 0
159+
index = 0
160+
for i in range(len(nums)):
161+
Sum += nums[i]
162+
while Sum >= s:
163+
res = min(res, i-index+1)
164+
Sum -= nums[index]
165+
index += 1
166+
return 0 if res==float("inf") else res
167+
```
168+
173169

174170
Go:
175171
```go

problems/0494.目标和.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
示例:
2121

22-
输入:nums: [1, 1, 1, 1, 1], S: 3
23-
输出:5
24-
解释:
25-
26-
-1+1+1+1+1 = 3
27-
+1-1+1+1+1 = 3
28-
+1+1-1+1+1 = 3
29-
+1+1+1-1+1 = 3
30-
+1+1+1+1-1 = 3
22+
输入:nums: [1, 1, 1, 1, 1], S: 3
23+
输出:5
24+
25+
解释:
26+
-1+1+1+1+1 = 3
27+
+1-1+1+1+1 = 3
28+
+1+1-1+1+1 = 3
29+
+1+1+1-1+1 = 3
30+
+1+1+1+1-1 = 3
3131

3232
一共有5种方法让最终目标和为3。
3333

problems/0669.修剪二叉搜索树.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ class Solution {
265265
```
266266

267267
Python:
268+
268269
```python3
270+
269271
# Definition for a binary tree node.
270272
# class TreeNode:
271273
# def __init__(self, val=0, left=None, right=None):

problems/背包总结篇.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,6 @@
9595

9696

9797

98-
## 其他语言版本
99-
100-
101-
Java:
102-
103-
104-
Python:
105-
106-
107-
Go:
108-
109-
11098

11199

112100
-----------------------

0 commit comments

Comments
 (0)