Data Structures & AlgorithmsVery hardICPC regional · GATE CS

Problem: The number of partitions of 12 into parts of size at most 4 (order of parts does not matter) is what value?

  1. A. 19
  2. B. 77
  3. C. 47
  4. D. 34

Correct answer: D. 34

A coin-change style DP with parts 1, 2, 3, 4 (outer loop over parts) counts 34 partitions of 12. Allowing parts up to 3 only gives 19, parts up to 5 give 47, and 77 counts all partitions of 12.

More Coding Interview Problems questions

Exams that ask this topic