Data Structures & AlgorithmsHardTCS NQT · GATE CS

Coins of values 1, 5, 6 and 9 are available in unlimited supply. What is the minimum number of coins needed to make exactly 11?

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

Correct answer: C. 2

Greedy (largest coin first: 9 + 1 + 1) uses three coins, but 5 + 6 uses two. The DP over amounts, dp[v] = 1 + min dp[v − c], finds the exact minimum, which is the key fact for non-canonical systems.

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

Exams that ask this topic