Created
April 12, 2021 16:37
-
-
Save mvallebr/b48de95d4284b09d29aa0d050b5c6042 to your computer and use it in GitHub Desktop.
This file contains 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
from functools import lru_cache | |
class Solution: | |
def change(self, amount: int, coins: List[int]) -> int: | |
@lru_cache | |
def dfs(amt): | |
if amt == 0: return 1 | |
if amt < 0: return 0 | |
return sum(dfs(amt - coins[i]) for i in range(len(coins))) | |
return dfs(amount) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment