Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ac2179

Browse files
更新 完全背包理论基础 0139.单词拆分 0279.完全平方数 0322.零钱兑换 0377.组合总和IV 0518.零钱兑换II 多重背包理论基础 背包总结篇 排版格式修复
1 parent fc19feb commit 7ac2179

8 files changed

+80
-66
lines changed

‎problems/0139.单词拆分.md‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
* 输入: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
3434
* 输出: false
3535

36-
# 算法公开课
36+
## 算法公开课
3737

38-
**《代码随想录》算法视频公开课:[你的背包如何装满?| LeetCode:139.单词拆分](https://www.bilibili.com/video/BV1pd4y147Rh/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
38+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[你的背包如何装满?| LeetCode:139.单词拆分](https://www.bilibili.com/video/BV1pd4y147Rh/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
3939

4040

4141
## 思路
@@ -123,7 +123,7 @@ public:
123123
124124
**这个代码就可以AC了,当然回溯算法不是本题的主菜,背包才是!**
125125
126-
## 背包问题
126+
### 背包问题
127127
128128
单词就是物品,字符串s就是背包,单词能否组成字符串s,就是问物品能不能把背包装满。
129129
@@ -239,7 +239,7 @@ public:
239239

240240
}
241241
};
242-
```
242+
```
243243

244244
使用用例:s = "applepenapple", wordDict = ["apple", "pen"],对应的dp数组状态如下:
245245

@@ -259,8 +259,8 @@ public:
259259

260260
## 其他语言版本
261261

262+
### Java:
262263

263-
Java:
264264
```java
265265
class Solution {
266266
public boolean wordBreak(String s, List<String> wordDict) {
@@ -335,7 +335,7 @@ class Solution {
335335
}
336336
```
337337

338-
Python:
338+
### Python:
339339

340340
回溯
341341
```python
@@ -397,7 +397,8 @@ class Solution:
397397

398398

399399

400-
Go:
400+
### Go:
401+
401402
```Go
402403
func wordBreak(s string,wordDict []string) bool {
403404
wordDictSet := make(map[string]bool)
@@ -433,7 +434,8 @@ func wordBreak(s string, wordDict []string) bool {
433434
}
434435
```
435436

436-
Javascript:
437+
### JavaScript:
438+
437439
```javascript
438440
const wordBreak = (s, wordDict) => {
439441

@@ -454,7 +456,7 @@ const wordBreak = (s, wordDict) => {
454456
}
455457
```
456458

457-
TypeScript:
459+
### TypeScript:
458460

459461
> 动态规划
460462

@@ -496,7 +498,7 @@ function wordBreak(s: string, wordDict: string[]): boolean {
496498
};
497499
```
498500

499-
Rust:
501+
### Rust:
500502

501503
```rust
502504
impl Solution {
@@ -519,3 +521,4 @@ impl Solution {
519521
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
520522
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
521523
</a>
524+

‎problems/0279.完全平方数.md‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
提示:
2929
* 1 <= n <= 10^4
3030

31-
# 算法公开课
31+
## 算法公开课
3232

33-
**《代码随想录》算法视频公开课:[换汤不换药!| LeetCode:279.完全平方数](https://www.bilibili.com/video/BV12P411T7Br/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
33+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[换汤不换药!| LeetCode:279.完全平方数](https://www.bilibili.com/video/BV12P411T7Br/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
3434

3535

3636
## 思路
@@ -106,8 +106,6 @@ dp[5] = min(dp[4] + 1, dp[1] + 1) = 2
106106
107107
最后的dp[n]为最终结果。
108108
109-
## C++代码
110-
111109
以上动规五部曲分析完毕C++代码如下:
112110
113111
```CPP
@@ -165,8 +163,8 @@ public:
165163
166164
## 其他语言版本
167165
166+
### Java:
168167
169-
Java:
170168
```Java
171169
class Solution {
172170
// 版本一,先遍历物品, 再遍历背包
@@ -219,7 +217,7 @@ class Solution {
219217
}
220218
```
221219

222-
Python:
220+
### Python:
223221

224222
先遍历物品, 再遍历背包
225223
```python
@@ -276,7 +274,8 @@ class Solution:
276274

277275

278276
```
279-
Go:
277+
### Go:
278+
280279
```go
281280
// 版本一,先遍历物品, 再遍历背包
282281
func numSquares1(n int) int {
@@ -327,7 +326,8 @@ func min(a, b int) int {
327326
}
328327
```
329328

330-
Javascript:
329+
### Javascript:
330+
331331
```Javascript
332332
// 先遍历物品,再遍历背包
333333
var numSquares1 = function(n) {
@@ -357,7 +357,7 @@ var numSquares2 = function(n) {
357357
};
358358
```
359359

360-
TypeScript:
360+
### TypeScript:
361361

362362
```typescript
363363
// 先遍历物品
@@ -389,7 +389,7 @@ function numSquares(n: number): number {
389389
};
390390
```
391391

392-
Rust:
392+
### Rust:
393393

394394
```rust
395395
// 先遍历背包
@@ -439,3 +439,4 @@ impl Solution {
439439
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
440440
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
441441
</a>
442+

‎problems/0322.零钱兑换.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
* 1 <= coins[i] <= 2^31 - 1
4040
* 0 <= amount <= 10^4
4141

42-
# 算法公开课
42+
## 算法公开课
4343

44-
**《代码随想录》算法视频公开课:[装满背包最少的物品件数是多少?| LeetCode:322.零钱兑换](https://www.bilibili.com/video/BV14K411R7yv/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
44+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[装满背包最少的物品件数是多少?| LeetCode:322.零钱兑换](https://www.bilibili.com/video/BV14K411R7yv/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
4545

4646

4747

@@ -110,7 +110,6 @@ dp[0] = 0;
110110

111111
dp[amount]为最终结果。
112112

113-
## C++代码
114113
以上分析完毕,C++ 代码如下:
115114

116115
```CPP
@@ -187,8 +186,8 @@ public:
187186

188187
## 其他语言版本
189188

189+
### Java:
190190

191-
Java:
192191
```Java
193192
class Solution {
194193
public int coinChange(int[] coins, int amount) {
@@ -215,7 +214,7 @@ class Solution {
215214
}
216215
```
217216
218-
Python:
217+
### Python:
219218
220219
221220
先遍历物品 后遍历背包
@@ -288,7 +287,8 @@ class Solution:
288287

289288
```
290289

291-
Go:
290+
### Go:
291+
292292
```go
293293
// 版本一, 先遍历物品,再遍历背包
294294
func coinChange1(coins []int, amount int) int {
@@ -352,7 +352,7 @@ func min(a, b int) int {
352352

353353
```
354354

355-
Rust:
355+
### Rust:
356356

357357
```rust
358358
// 遍历物品
@@ -398,7 +398,8 @@ impl Solution {
398398
}
399399
```
400400

401-
Javascript:
401+
### Javascript:
402+
402403
```javascript
403404
// 遍历物品
404405
const coinChange = (coins, amount) => {
@@ -435,7 +436,7 @@ var coinChange = function(coins, amount) {
435436
}
436437
```
437438

438-
TypeScript:
439+
### TypeScript:
439440

440441
```typescript
441442
// 遍历物品
@@ -473,3 +474,4 @@ function coinChange(coins: number[], amount: number): number {
473474
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
474475
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
475476
</a>
477+

‎problems/0377.组合总和IV.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
因此输出为 7。
3333

34-
# 算法公开课
34+
## 算法公开课
3535

36-
**《代码随想录》算法视频公开课:[装满背包有几种方法?求排列数?| LeetCode:377.组合总和IV](https://www.bilibili.com/video/BV1V14y1n7B6/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
36+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[装满背包有几种方法?求排列数?| LeetCode:377.组合总和IV](https://www.bilibili.com/video/BV1V14y1n7B6/),相信结合视频再看本篇题解,更有助于大家对本题的理解**
3737

3838
## 思路
3939

@@ -154,8 +154,7 @@ C++测试用例有两个数相加超过int的数据,所以需要在if里加上
154154
155155
## 其他语言版本
156156
157-
158-
Java:
157+
### Java:
159158
160159
```Java
161160
class Solution {
@@ -174,7 +173,7 @@ class Solution {
174173
}
175174
```
176175

177-
Python:
176+
### Python:
178177

179178

180179
卡哥版
@@ -207,7 +206,8 @@ class Solution:
207206

208207

209208
```
210-
Go:
209+
### Go:
210+
211211
```go
212212
func combinationSum4(nums []int, target int) int {
213213
//定义dp数组
@@ -226,7 +226,8 @@ func combinationSum4(nums []int, target int) int {
226226
}
227227
```
228228

229-
Javascript:
229+
### Javascript:
230+
230231
```javascript
231232
const combinationSum4 = (nums, target) => {
232233

@@ -245,7 +246,7 @@ const combinationSum4 = (nums, target) => {
245246
};
246247
```
247248

248-
TypeScript:
249+
### TypeScript:
249250

250251
```typescript
251252
function combinationSum4(nums: number[], target: number): number {
@@ -264,7 +265,7 @@ function combinationSum4(nums: number[], target: number): number {
264265
};
265266
```
266267

267-
Rust
268+
### Rust:
268269

269270
```Rust
270271
impl Solution {
@@ -289,3 +290,4 @@ impl Solution {
289290
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
290291
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
291292
</a>
293+

0 commit comments

Comments
(0)

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