Question DSA-DP-0044
MediumWhat is the output of this code?
def min_coins(n, coins):
INF = float("inf")
d = [0] + [INF] * n
for s in range(1, n + 1):
for c in coins:
if c <= s:
d[s] = min(d[s], d[s - c] + 1)
return d[n]
print(min_coins(11, [1, 5, 6, 9]))
- A.
4
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.