Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Using US coin denominations 1, 5, 10, 25, what is the minimum number of coins needed to make 63 (greedy works for these denominations)?

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

Correct answer: D. 6

Greedy: 25 + 25 + 10 + 1 + 1 + 1 = 63, six coins, which is optimal for this canonical set. 3 counts the denominations used, using two nickels instead of a dime gives 7, and 2 quarters + 13 pennies gives 15.

More Coding Interview Problems questions

Exams that ask this topic