Question DSA-DP-0008
MediumWhat is the output of this code?
coins, amt = [1, 2, 5], 11
INF = float('inf')
dp = [0] + [INF] * amt
for x in range(1, amt + 1):
for c in coins:
if c <= x:
dp[x] = min(dp[x], dp[x - c] + 1)
print(dp[amt])
- A.
2
- B.
4
- C.
Sign up free to see the answer and a step-by-step explanation.