Data Structures & AlgorithmsModerateTCS NQT · GATE CS

How many ways are there to make 15 using coins of values 1, 2, 5 and 10, where the order of coins does not matter (so 5+5+5 and 5+10 are different ways, but 1+2+2 and 2+1+2 count once)?

  1. A. 22
  2. B. 18
  3. C. 19
  4. D. 6

Correct answer: A. 22

Count unordered combinations: loop over coin types on the outside and amounts ascending on the inside, so each coin type can repeat but the order of different coins is never counted. Looping amounts on the outside counts orderings instead.

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

Exams that ask this topic