Data Structures & AlgorithmsHardICPC regional · GATE CS top band

Coins of denominations [12, 10, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 20? (Coins may be used any number of times; the answer must sum exactly.)

  1. A. 20
  2. B. 5
  3. C. 4
  4. D. 2

Correct answer: D. 2

The unbounded DP gives 2 coins. The greedy largest-first rule uses 5, which is the trap when denominations are not canonical.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic