Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The number of subsets of {1, 2, 3, 4} whose elements sum to exactly 5 (the empty set is excluded) is what value?

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

Correct answer: C. 2

The subsets with sum 5 are {1,4} and {2,3}, so the count is two.

More Coding Interview Problems questions

Exams that ask this topic