Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

What is the sum of the minimum over every window of size 2 in [5, 2, 8, 1, 9]?

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

Correct answer: C. 6

The four windows [5,2], [2,8], [8,1], [1,9] have minima 2, 2, 1, 1 which total 6. The sum of maxima (last option) is a different quantity.

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

Exams that ask this topic