1 动态规划(完全背包)
代码语言:javascript复制class Solution {
public:
int change(int amount, vector<int>& coins) {
vector<int> dp(amount 1, 0);
dp[0] = 1;
for (int i = 0; i < coins.size(); i )
// 完全背包:背包容量for循环升序
for (int j = coins[i]; j <= amount; j )
dp[j] = dp[j] dp[j - coins[i]];
return dp[amount];
}
};