Data Structures & AlgorithmsHard

How many split points i (0 ≤ i ≤ n−2) of 2 5 1 4 3 6 2 7 satisfy: (sum of A[0..i]) mod 3 equals (sum of A[i+1..n−1]) mod 3?

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

Correct answer: C. 3

Each split is judged on the residues of its two sides, computed from prefix and suffix sums. Testing exact equality, shifting the split by one, or comparing with the full sum instead changes the set of qualifying splits.

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

Exams that ask this topic