Data Structures & AlgorithmsVery hardProduct company OA · Amazon/Microsoft-style OA

Four sets {1,2,3}, {2,4}, {3,4,5}, {1,5} are given. How many non-empty sub-collections of these sets have a union equal to {1, 2, 3, 4, 5}?

  1. A. 8
  2. B. 6
  3. C. 5
  4. D. 9

Correct answer: B. 6

Enumerate the 15 non-empty sub-collections and test each union; the count is over sub-collections, not over elements. Counting minimal covers alone gives a smaller number, which is the common confusion.

More Coding Interview Problems questions

Exams that ask this topic