Skip to content

Instantly share code, notes, and snippets.

@khatv911
Created February 20, 2019 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khatv911/780b1cfdf4049dca6efbaafb4b3f59fe to your computer and use it in GitHub Desktop.
Save khatv911/780b1cfdf4049dca6efbaafb4b3f59fe to your computer and use it in GitHub Desktop.
Coin change
fun coinChange(n, coins)
dp=[]// n+1 items
dp[0]=0
for i from 1 to n
minCoins = maxint
for(coin in coins)
if(i >= coin)
min = Math.min(min, dp[i -coin]+1)
dp[i] = min
Return dp[n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment