Data Structures & AlgorithmsHardGATE CS · DSA

A monotonic deque reports the maximum of every window of size 3 in [0, 13, 9, 1, 2, 18, −1, −3, 17]. What is the SUM of all reported window maxima?

  1. A. 106
  2. B. 119
  3. C. 97
  4. D. 72

Correct answer: A. 106

Window maxima: [13, 13, 9, 18, 18, 18, 17], summing to 106. Taking the 7 largest elements overall double-counts big values that dominate several windows only once.

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

Exams that ask this topic