Leetcode 518 Solution
This article provides solution to leetcode question 518 (coin-change-2).
Access this page by simply typing in "lcs 518" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/coin-change-2
Solution
class Solution:
def change(self, amount: int, coins: List[int]) -> int:
dp = [0] * (amount + 1)
dp[0] = 1
for coin in coins:
for i in range(amount + 1):
if i - coin >= 0:
dp[i] += dp[i - coin]
return dp[-1]