Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

Consider all non-empty contiguous subarrays of [2, 7, 3, 8, 6]. For each, take its sum modulo 10. What is the largest of these residues?

  1. A. 26
  2. B. 9
  3. C. 8
  4. D. 6

Correct answer: B. 9

For each prefix P[j], look for the smallest earlier prefix residue just above P[j] mod 10; here [2, 7] gives 9, the maximum possible. Reducing the largest sum (the whole array, 26) gives only 6, and 8 is just the largest element.

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

Exams that ask this topic