Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

With 1-based indexing, what is the sum of i times a[i] for a = [2, 0, 3, 1]?

  1. A. 15
  2. B. 9
  3. C. 12
  4. D. 17

Correct answer: A. 15

With 1-based indices the weights are 1, 2, 3, 4, giving 2 + 0 + 9 + 4 = 15. Using 0-based indices (the first option) changes every weight.

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

Exams that ask this topic