Data Structures & AlgorithmsModerateProduct Company SDE · CP practice

Problem: A 3-person committee is chosen from 6 people. How many committees include at least one of two specific people A or B? Run the code.

Problem: A 3-person committee is chosen from 6 people. How many committees include at least one of two specific people A or B? Run the code.
from math import comb
print(comb(6, 3) - comb(4, 3))
What is printed?
  1. A. 20
  2. B. 12
  3. C. 16
  4. D. 4

Correct answer: C. 16

Total committees are C(6,3) = 20, and those avoiding both A and B are C(4,3) = 4, so 16 include at least one.

More Coding Interview Problems questions

Exams that ask this topic