Skip to content

Commit 8d41a21

Browse files
authored
DP it is
1 parent 1c10c18 commit 8d41a21

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Coin change 2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int change(int amount, vector<int>& coins) {
4+
vector<int> dp(amount+1,0);
5+
dp[0]=1;
6+
for(int c:coins)
7+
{
8+
for(int i=c;i<=amount;i++)
9+
dp[i]+=dp[i-c];
10+
}
11+
return dp[amount];
12+
}
13+
};

0 commit comments

Comments
 (0)