Skip to content

Instantly share code, notes, and snippets.

@anshumanatri
Created March 12, 2009 10:09
Show Gist options
  • Save anshumanatri/77987 to your computer and use it in GitHub Desktop.
Save anshumanatri/77987 to your computer and use it in GitHub Desktop.
Change(d,k,n)
c[0] = 0
for p = 1 to n do
min = INFINITY
for i = 1 to k do
if(d[i] <= p) do
if( 1 + c[p - d[i]] < min) then
min = 1 + c[p - d[i]]
coin = i
c[p] = min
s[p] = coin
return c & s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment