Data Structures & AlgorithmsHardGATE CS · TCS NQT

Coins of value 2, 3 and 5 are available in unlimited supply. In how many ways can you pay exactly 10 when the ORDER of coins does NOT matter (for example 2+3+5 and 5+3+2 count as the same way)?

  1. A. 14
  2. B. 4
  3. C. 2
  4. D. 8

Correct answer: B. 4

Unordered counting uses the outer loop over coins: each coin type is processed once, and the inner loop goes upward so a coin can repeat. Looping over the amount first, as an ordered count does, counts each permutation separately.

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

Exams that ask this topic