mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新代码块
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
所以本题遍历顺序最终遍历顺序:**target(背包)放在外循环,将nums(物品)放在内循环,内循环从前到后遍历**。
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
class Solution {
|
||||
public:
|
||||
int combinationSum4(vector<int>& nums, int target) {
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
和昨天的题目[动态规划:377. 组合总和 Ⅳ](https://mp.weixin.qq.com/s/Iixw0nahJWQgbqVNk8k6gA)基本就是一道题了,遍历顺序也是一样一样的!
|
||||
|
||||
代码如下:
|
||||
```C++
|
||||
```CPP
|
||||
class Solution {
|
||||
public:
|
||||
int climbStairs(int n) {
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
|
||||
外层for循环遍历物品,内层for遍历背包:
|
||||
```C++
|
||||
```CPP
|
||||
// 版本一
|
||||
class Solution {
|
||||
public:
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
外层for遍历背包,内层for循环遍历物品:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
// 版本二
|
||||
class Solution {
|
||||
public:
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
|
||||
先遍历背包,在遍历物品:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
// 版本一
|
||||
class Solution {
|
||||
public:
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
|
||||
先遍历物品,在遍历背包:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
// 版本二
|
||||
class Solution {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user