1 <= coins.length <= 12
1 <= coins[i] <= 231 - 1
0 <= amount <= 104
int coinChange(vector<int>& coins, int amount) {
if(amount==0)
{
return 0;
}
vector<int>dp(amount+1,INT_MAX);
for(int i=0;i<coins.size();i++)
{
if(coins[i]>amount)
{
continue;
}
dp[coins[i]]=1;
}
for(int i=0;i<=amount;i++)
{
if(dp[i]==1)
{
continue;
}
for(int j=i-1;j>=i/2;j--)
{
long tmp = (long)dp[j]+(long)dp[i-j];
if(tmp <dp[i])
{
dp[i]=tmp;
}
}
}
if(dp[amount]==INT_MAX)
{
return -1;
}
return dp[amount];
}