Advertisement
nikunjsoni

518

Jun 12th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int change(int amount, vector<int>& coins) {
  4.         vector<int> dp(amount+1);
  5.         dp[0] = 1;
  6.        
  7.         for(int coin:coins){
  8.             for(int i=1; i<=amount; i++)
  9.                 if(i>=coin)
  10.                     dp[i] += dp[i-coin];
  11.         }
  12.         return dp[amount];
  13.     }
  14. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement