Bug Report for https://neetcode.io/problems/coin-change
In the Test Case coins=[2], amount=3, it passed during the first run, but after submission, it didn't work.
I even ran it locally and it gives the correct result
Here's My Solution:
class Solution:
dp = {}
def coinChange(self, coins: List[int], amount: int) -> int:
if amount < 0:
return -1
if amount == 0:
return 0
result = 2147483647
for c in coins:
if amount - c >= 0:
if not (amount - c) in self.dp:
self.dp[amount - c] = self.coinChange(coins, amount - c)
if self.dp[amount - c] == -1:
continue
result = min(self.dp[amount - c] + 1, result)
return -1 if result == 2147483647 else result
Bug Report for https://neetcode.io/problems/coin-change
In the Test Case coins=[2], amount=3, it passed during the first run, but after submission, it didn't work.
I even ran it locally and it gives the correct result
Here's My Solution: