Data Structures & AlgorithmsModerateTCS Digital · Infosys SP

An equilibrium index i has (sum of elements left of i) = (sum of elements right of i), excluding a[i]. Which indices of [0, 9, 2, 3, 4, 2, 3, 5, −3] (0-based) are equilibrium indices?

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

Correct answer: B. 3

Total = 25. Scan with a running left sum L: index i works when L = total − L − a[i]. That holds at 3.

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

Exams that ask this topic