Last active
September 2, 2019 21:49
-
-
Save mofas/49155b6f01a312c3944da3d807fab778 to your computer and use it in GitHub Desktop.
Coin changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dfs (remainCoins, target): | |
if target === 0: | |
# calculate what coins you used here | |
usedCoin = ... | |
results.append(usedCoin) | |
return | |
if target < 0: | |
return | |
for coin in remainCoins: | |
if remainCoins[coin] > 0: | |
remainCoins[coin]-= 1 | |
dfs(remainCoins, target - coin) | |
remainCoins[coin]+= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment