knakul853

Untitled

Jun 27th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. /**
  2. knakul853
  3. **/
  4. class Solution {
  5. public:
  6.     int change(int amount, vector<int>& coins) {
  7.        
  8.         vector<int>dp(amount+1);
  9.         dp[0] = 1;
  10.        
  11.         for( int coin : coins )
  12.         {
  13.             for( int j=coin; j<=amount; j++ )
  14.             {
  15.                 dp[j] += dp[j-coin];
  16.             }
  17.         }
  18.        
  19.         return dp[amount];
  20.        
  21.     }
  22. };
Add Comment
Please, Sign In to add comment