Pick the fix
Which question is the best fit for DP?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Count the ways to pay 50 with coins 1, 2 and 5
Right: counting over choices, with repeated sub-amounts.
Counting can reuse sub-answers without writing each combination down, which is where DP wins.
Why not the others?
- B List every way to pay 50 with coins 1, 2 and 5. Listing needs every answer written out: backtracking.
- C Pay 50 with the fewest coins from 1, 2, 5, 10, 20. That coin system works greedily, so DP is unnecessary.