Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

What is the sum over all adjacent pairs of [4, 2, 5, 1, 3] of the smaller of the two values?

  1. A. 7
  2. B. 17
  3. C. 6
  4. D. 4

Correct answer: C. 6

Each adjacent pair contributes its minimum: 2, 2, 1, 1, giving 6. The sum of maxima is a different quantity.

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

Exams that ask this topic