Data Structures & AlgorithmsHardGATE CS · ICPC regional

Coins of denominations [2, 7, 11, 13] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 58?

  1. A. 7
  2. B. 5
  3. C. 33
  4. D. 6

Correct answer: D. 6

The greedy rule (largest coin first) is optimal only for canonical coin systems. Here a dynamic program over amounts finds a smaller coin count than greedy. The number of ways to pay is a different question.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic