Data Structures & AlgorithmsModerateCAT · TCS NQT

Problem: How many subsets of {1, 2, 3, 4, 5, 6} contain exactly two odd numbers?

  1. A. 15
  2. B. 3
  3. C. 24
  4. D. 64

Correct answer: C. 24

Choose 2 of the odds {1, 3, 5} in 3 ways and any subset of the evens in 2³ = 8 ways: 24. C(6,2) = 15 picks any two numbers, 3 forgets the evens, and 64 counts all subsets.

More Coding Interview Problems questions

Exams that ask this topic