Data Structures & AlgorithmsModerateProduct company OA · Amazon/Microsoft-style OA

How many 3-element subsets of {1, 2, 3, 4, 5, 6, 7, 8} have a sum divisible by 6?

  1. A. 10
  2. B. 12
  3. C. 7
  4. D. 20

Correct answer: A. 10

Enumerate pairs and look up the needed third value, or split into two halves and match residues mod 6. Ignoring the size-3 restriction or testing divisibility by 3 rather than by 6 changes the count.

More Coding Interview Problems questions

Exams that ask this topic