leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0518.cpp (317B)


      1 class Solution {
      2   public:
      3     int change(int amount, vector<int> &coins) {
      4         vector<long long> dp(amount + 1, 0);
      5         dp[0] = 1;
      6 
      7         for (int coin : coins)
      8             for (int i = 0; i <= amount; i++)
      9                 if (i - coin >= 0) dp[i] += dp[i - coin];
     10 
     11         return (int)dp.back();
     12     }
     13 };