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?
- A. 3
- B. 11
- C. 2
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- In how many ways can 100 paise be paid using coins of 1, 5, 10 and 25 paise, where the order of coins does not matter?
- In how many ways can 9 identical sweets be given to 4 distinct children so that every child gets at least one sweet?
- How many words of length 6 over a three-letter alphabet {x, y, z} have no two adjacent letters equal?
- How many permutations p of 1, 2, ..., 6 satisfy p[i] ≤ i + 1 for every position i (1-based)?
- How many distinct arrangements of the letters of "aabbcc" have no two adjacent letters equal?
- Count monotone lattice paths from (0, 0) to (3, 3) that move one step right (x+1) or up (y+1) and never touch a point (i, i) with 0 < i <…