Data Structures & AlgorithmsHardTCS NQT Digital · CAT

Problem: For the set {1, 2, 3, 4, 5, 6, 7, 8}, how many 3-element subsets have a sum that is even?

  1. A. 28
  2. B. 56
  3. C. 4
  4. D. 24

Correct answer: A. 28

An even sum needs 0 or 2 odd elements: C(4,3) + C(4,2) · C(4,1) = 4 + 24 = 28. 56 counts every 3-subset, 4 counts only all-even subsets, and 24 forgets the all-even case.

More Coding Interview Problems questions

Exams that ask this topic