Bug Report for https://neetcode.io/problems/coin-change
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
The following is memoization method to resolve the problem and passing leetcode submission. But it fails neetcode submission.
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
# memoization
solns = [None] * (amount + 1)
def dfs(amount):
if amount < 0:
return float("+inf")
if solns[amount] != None:
return solns[amount]
if amount == 0:
solns[amount] = 0
else:
res = float("+inf")
for c in coins:
temp = 1 + dfs(amount - c)
res = min(res, temp)
solns[amount] = res
return solns[amount]
res = dfs(amount)
return res if res < float("+inf") else -1
Bug Report for https://neetcode.io/problems/coin-change
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
The following is memoization method to resolve the problem and passing leetcode submission. But it fails neetcode submission.
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
# memoization
solns = [None] * (amount + 1)