Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

coin change top-down

for (int i = 0; i < coins.size(); ++i) {
    if (coins[i] <= target) { // check validity of a sub-problem
        result = min(ans, CoinChange(target - coins[i], coins) + 1);
    }
}
return memo[target] = result;
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #coin #change
ADD COMMENT
Topic
Name
5+5 =