Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many windows of size 3 in [5, 2, 7, 3, 1, 6, 4] have their minimum exactly at the middle position?

  1. A. 3
  2. B. 1
  3. C. 2
  4. D. 4

Correct answer: C. 2

Check the middle value against the window minimum; each window needs only that comparison. A tie with an endpoint still counts as minimal at the middle when equal.

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

Exams that ask this topic