forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename 518.Coin-Change-2.cpp to 518.Coin-Change-2_v2.cpp
- Loading branch information
1 parent
dbef7fb
commit c180096
Showing
2 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2.cpp
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
Dynamic_Programming/518.Coin-Change-2/518.Coin-Change-2_v2.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
}; |