Data Structures & AlgorithmsHard

How many contiguous subarrays of 3 5 7 2 9 1 13 have a product that leaves remainder 1 when divided by 4?

  1. A. 8
  2. B. 4
  3. C. 12
  4. D. 9

Correct answer: A. 8

Only the residue of the product mod 4 matters, and each element's residue multiplies in turn. Residue 3 is a different class, odd products are a coarser test, and excluding singletons drops real qualifiers.

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

Exams that ask this topic