Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: In how many ways can 15 be written as a sum of distinct odd positive integers (order does not matter)?

  1. A. 5
  2. B. 3
  3. C. 6
  4. D. 4

Correct answer: D. 4

Enumerate subsets of the odd numbers up to 15 and count those whose sum is 15. A standard subset-sum DP gives the same answer; counting ordered sums would be far larger.

More Coding Interview Problems questions

Exams that ask this topic