Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

How many indices i in [1, 7, 3, 6, 5, 6] have the sum of elements strictly left of i equal to the sum of elements strictly right of i?

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

Correct answer: A. 1

Use the total sum and a running prefix: the right-side sum is total minus prefix minus a[i]. Including the element itself on one side is a common off-by-one in pivot problems.

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

Exams that ask this topic