Skip to content

Commit

Permalink
Update and rename 518.Coin-Change-2.cpp to 518.Coin-Change-2_v2.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Nov 8, 2020
1 parent dbef7fb commit c180096
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 0 additions & 17 deletions Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2.cpp

This file was deleted.

17 changes: 17 additions & 0 deletions Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2_v2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 (int c=1; c<=amount; c++)
{
if (c>=coins[i])
dp[c] += dp[c-coins[i]];
}
}
return dp[amount];
}
};

0 comments on commit c180096

Please sign in to comment.