int coinChange(vector<int> &coins, int amount) {
vector<int> ans(amount + 1, amount+10);
ans[0] = 0;
for (int i = 1; i < amount+1; i++) {
for (int j = 0; j < coins.size(); j++)
if (i >= coins[j])
ans[i] = min(ans[i], ans[i - coins[j]] + 1);
}
if(ans.back()<amount+1) return ans.back();
else return -1;
}
dp:bottom-up做法