当前位置:网站首页>leetcode - 518. Change II
leetcode - 518. Change II
2022-06-11 08:43:00 【zmm_ mohua】
leetcode - 518. Change for II
subject

Code
#include <iostream>
#include <vector>
using namespace std;
int change(int amount, vector<int>& coins) {
vector<int> dp(amount+1);
dp[0] = 1; // The amount of money is 0 when , Means you don't take any change , So it is 1
for(int i = 0; i < coins.size(); i++){
int coin = coins[i];
for(int j = coin; j <= amount; j++){
dp[j] += dp[j-coin];
}
}
return dp[amount];
}
int main(){
int n, amount, res;
cin>>n>>amount;
vector<int> coins(n);
for(int i = 0; i < n; i++){
cin>>coins[i];
}
res = change(amount, coins);
cout<<res;
return 0;
}
边栏推荐
- 剑指 Offer 62. 圆圈中最后剩下的数字
- Typescript keyboard mapping
- Solve valueerror: no model found in config file
- js 中 Map 和 Set 的用法及区别
- Node error report sorting
- BFS on tree (tree breathing first search)
- SSM file upload and download
- 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
- Hibernate L2 cache
- Go language: string connection, digital conversion string
猜你喜欢

Difference between threadpooltaskexecutor and ThreadPoolExecutor

B+ super tree helps you know the underlying structure of MySQL

指定环境下安装Jupyter

Idea annotation settings

并查集是什么?你还在为其烦恼?其实就是一个连通图的问题,理解起来没有那么困难

Sign in system design: how to draw the sign in function

torch. Var (), sample variance, parent variance

Jupyter notebook code completion plug-in + Solution

Asynchronous notification mechanism of character device driver

Is the result too different from the goal? With the help of target management, you can reach the target accurately!
随机推荐
Zookepper===>动物管理员系统
Solution to the occurrence interval (space) of latex manual numbering documents
ActiveMQ简单教程,适合初学者,学习笔记yyds
What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand
Entity class conversion cannot be reassigned
Testing firebase with postman
qiao-lerna:lerna辅助工具
mysql高级特性篇,可以多看看,应付面试
AttributeError: module ‘tensorflow. compat. v2.__ internal__‘ has no attribute ‘register_ clear_ session_
Web design and website planning assignment 13 making video playlists
Solve ('You must install pydot (`pip install pydot`) and install graphviz (see...) '‘ for plot_ model..
MySQL upgrade
Modulenotfounderror: no module named 'tensorboard in pytorch‘
The difference between equals and = =
Classical graph theory, depth first and breadth first, topology, prim and krukal, it's time to review
Idea pulls items from remote warehouse
Empty difference between postgrepsql and Oracle
torch. meshgrid
ActiveMQ simple tutorial, suitable for beginners, learning notes yyds
剑指 Offer 40. 最小的k个数