Data Structures & AlgorithmsHardTCS Digital · Infosys SP

A monotonic deque reports the maximum of every window of size 3 in [19, 6, 7, 16, 10, 2, 12, 8, 17]. What is the SUM of all reported window maxima?

  1. A. 101
  2. B. 108
  3. C. 127
  4. D. 92

Correct answer: B. 108

Window maxima: [19, 16, 16, 16, 12, 12, 17], summing to 108. 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