Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA

How many subsets of {1, 2, ..., 10} have a sum of exactly 10? The single-element subset {10} counts as one of them.

  1. A. 9
  2. B. 12
  3. C. 20
  4. D. 10

Correct answer: D. 10

Meet in the middle splits the ten values into two halves, counts matching sums across the halves, and adds the counts. Single-element subsets and subsets such as {1, 2, 3, 4} are included, and dropping {10} is the off-by-one trap.

More Coding Interview Problems questions

Exams that ask this topic