var coinChange = function(coins, amount) { return dp(coins,amount); };
var dp=function(coins,amount){ if(amount==0) return 0; if(amount<0) return -1; let res =Infinity; for(let coin in coins) { let sub=dp(coins,amount-coin); if(sub==-1) continue; res=Math.min(res,sub+1); } return res==Infinity?-1:res; };