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