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

This commit is contained in:
jinbudaily
2023-07-26 15:28:27 +08:00
parent fc19feb049
commit 7ac217942f
8 changed files with 80 additions and 66 deletions

View File

@@ -28,9 +28,9 @@
提示:
* 1 <= n <= 10^4
# 算法公开课
## 算法公开课
**《代码随想录》算法视频公开课:[换汤不换药!| LeetCode279.完全平方数](https://www.bilibili.com/video/BV12P411T7Br/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[换汤不换药!| LeetCode279.完全平方数](https://www.bilibili.com/video/BV12P411T7Br/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
## 思路
@@ -106,8 +106,6 @@ dp[5] = min(dp[4] + 1, dp[1] + 1) = 2
最后的dp[n]为最终结果。
## C++代码
以上动规五部曲分析完毕C++代码如下:
```CPP
@@ -165,8 +163,8 @@ public:
## 其他语言版本
### Java
Java
```Java
class Solution {
// 版本一,先遍历物品, 再遍历背包
@@ -219,7 +217,7 @@ class Solution {
}
```
Python
### Python
先遍历物品, 再遍历背包
```python
@@ -276,7 +274,8 @@ class Solution:
```
Go
### Go
```go
// 版本一,先遍历物品, 再遍历背包
func numSquares1(n int) int {
@@ -327,7 +326,8 @@ func min(a, b int) int {
}
```
Javascript:
### Javascript:
```Javascript
// 先遍历物品,再遍历背包
var numSquares1 = function(n) {
@@ -357,7 +357,7 @@ var numSquares2 = function(n) {
};
```
TypeScript
### TypeScript
```typescript
// 先遍历物品
@@ -389,7 +389,7 @@ function numSquares(n: number): number {
};
```
Rust:
### Rust:
```rust
// 先遍历背包
@@ -439,3 +439,4 @@ impl Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>