Data Structures & AlgorithmsModerate

How many NON-EMPTY subsets of [3, 6, 9, 12, 15, 4, 8, 11] (chosen by index, so equal values are different elements) have a sum divisible by 3?

  1. A. 95
  2. B. 96
  3. C. 90
  4. D. 64

Correct answer: A. 95

Counting subsets by index over 2^n choices, the empty subset (sum 0) is divisible by 3 but is not allowed. Including it adds one, dropping the singletons loses real answers, and a remainder-1 count answers a different question.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic