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

How many subsets (including the empty subset) of [3, 5, 9, 11, 14, 2] have a sum divisible by 7?

  1. A. 13
  2. B. 14
  3. C. 9
  4. D. 1

Correct answer: B. 14

A DP over sums mod 7 (or the 64 bitmasks) gives 14 subsets including the empty one. Excluding the empty set gives 13, assuming 64 / 7 ≈ 9 gives 9, and counting only sum exactly 7 gives 1 ({5, 2}).

More Coding Interview Problems questions

Exams that ask this topic