Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C

Problem: How many contiguous subarrays of [7, 2, 9, 4, 1, 8, 3, 5, 6, 10] have a sum divisible by 7?

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

Correct answer: A. 5

Prefix sums modulo 7 with a count of seen residues: two prefixes with equal residue bracket a divisible-by-7 subarray. The empty prefix (residue 0) must be counted initially.

More Coding Interview Problems questions

Exams that ask this topic