Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

What is the sum of the maxima of every window of size 2 in [9, 4, 7, 1, 8]?

  1. A. 32
  2. B. 31
  3. C. 30
  4. D. 10

Correct answer: B. 31

Window maxima are 9, 7, 7, 8 which total 31. Taking the window minima (the last option) produces a smaller and different sum.

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

Exams that ask this topic