Data Structures & AlgorithmsModerate

How many NON-EMPTY subsequences of 2 3 4 5 6 8 (position subsets) have a product congruent to 1 modulo 7?

  1. A. 12
  2. B. 0
  3. C. 11
  4. D. 10

Correct answer: C. 11

Track the residue of the product mod 7 as a DP over the items; the target residue 1 is distinct from residue 6 (which equals −1). The empty subsequence has an empty product of 1, so it must be excluded explicitly.

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

Exams that ask this topic