Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

How many contiguous subarrays of length at least 2 of [23, 2, 4, 6, 7] have a sum that is a multiple of 6?

  1. A. 3
  2. B. 4
  3. C. 2
  4. D. 5

Correct answer: A. 3

Prefix sums modulo k: two prefixes with equal remainder bound a subarray divisible by k. Requiring length at least 2 removes the single-element subarray 6 from the count.

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

Exams that ask this topic