Data Structures & AlgorithmsHardICPC regional · TCS NQT Digital

Problem: A bag holds coins of values 1, 4 and 9. You must pay exactly 30 using as few coins as possible. What is the minimum number of coins?

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

Correct answer: D. 5

Unbounded coin DP finds the minimum number of coins. Taking the largest coin first gives 9+9+9+1+1+1 = 30 with six coins, but a better combination exists.

More Coding Interview Problems questions

Exams that ask this topic