Coin Change 2 LeetCode solution in Python

1
class Solution:
2
def change(self, amount: int, coins: List[int]) -> int:
3
leng = len(coins)
4

5
def dfs(amount, start):
6
if amount == 0:
7
return 1
8
elif amount < 0:
9
return 0
10
res = 0
11
for i in range(start, leng):
12
res += dfs(amount - coins[i], i)
13
return res
14

15
return dfs(amount, 0)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0