Data Structures & AlgorithmsHard

How many subsets of exactly two elements of 2 4 5 7 9 10 12 (position pairs) have a sum divisible by 3?

  1. A. 9
  2. B. 13
  3. C. 8
  4. D. 7

Correct answer: D. 7

Count the residues of the values mod 3 and combine the pairs whose residues sum to zero: (0,0), (1,2) and (2,1). Using residue 1, parity, or triples each count a different set.

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

Exams that ask this topic