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?
- A. 19
- B. 77
- C. 47
- 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
- Problem: The longest palindromic subsequence of "character" has what length?
- Problem: Ropes of lengths 4, 3, 2 and 6 are joined pairwise; joining two ropes costs the sum of their lengths, and the next join uses the…
- Problem: How many integers n with 1 ≤ n ≤ 100 have a binary representation that reads the same forwards and backwards?
- Problem: What is the sum of the smallest prime factors of the integers 2 through 30 (each integer contributes its smallest prime divisor)?
- Problem: How many positive divisors does the number 2^10 × 3^4 have?
- Problem: What are the last two decimal digits of 3^200?