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

Consider the eight primes 2, 3, 5, 7, 11, 13, 17, 19. How many subsets (including the empty subset, whose product is 1) have a product that is at most 500?

  1. A. 77
  2. B. 72
  3. C. 74
  4. D. 73

Correct answer: D. 73

Split the primes into two halves, enumerate the products of each half, and for each left product count right products at most 500 divided by it, using a sorted list and binary search. The empty subset counts with product 1, and a strict limit below 500 drops products equal to 500.

More Coding Interview Problems questions

Exams that ask this topic