C++,6-lines


  • 0
    Z

    C++,6-lines

    class Solution {
    public:
    int change(int amount, vector<int>& coins) {
        unordered_map <int,int>mapping;
        mapping[0]=1;
        for(int i=0;i<coins.size();i++){
            for(int j=coins[i];j<=amount;j++)
            mapping[j]+=mapping[j-coins[i]];
        }
        return mapping[amount];
    }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.