Data Structures & AlgorithmsHardTCS NQT · Infosys

Coins of denominations 1, 3 and 4 are available in unlimited supply. What is the minimum number of coins needed to make exactly 6?

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

Correct answer: B. 2

Greedy (take the largest coin that fits) gives 4 + 1 + 1 = 3 coins, but 3 + 3 uses 2. The minimum must come from dp[v] = 1 + min(dp[v - coin]) over all coins, not from the greedy choice.

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

Exams that ask this topic