Data Structures & AlgorithmsModerateCodeforces Div2 B · DP warm-up

Problem: Coins of values {1, 5, 6, 9} are available, unlimited copies each. What is the minimum number of coins needed to make exactly 11?

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 11

Correct answer: A. 2

Greedy gives 9 + 1 + 1 = 3 coins, but 5 + 6 = 11 uses only 2 coins. Greedy fails for this coin system, so the optimum needs a DP over amounts.

More Coding Interview Problems questions

Exams that ask this topic