Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

With coins of denominations 1, 5, 6 and 9, what is the minimum number of coins needed to make the amount 15?

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

Correct answer: D. 2

A DP over amounts is needed: greedy takes 9 + 6 for two coins, which is optimal here, but the trap is the greedy that starts with the largest coin and ends with ones. Compare the DP value to see which is minimal.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic