Data Structures & AlgorithmsVery hardTCS NQT Digital · Product Company SDE

Problem: With coin denominations 1, 7 and 10, what is the minimum number of coins needed to make 97?

  1. A. 16
  2. B. 10
  3. C. 19
  4. D. 97

Correct answer: B. 10

The DP over amounts gives 9 × 10 + 7 = 97 with 10 coins; using more 7s only adds coins (8 tens need 2 sevens and 3 ones). Using only 10s and 1s gives 16, only 7s and 1s gives 13 + 6 = 19, and 97 is the all-ones count.

More Coding Interview Problems questions

Exams that ask this topic