Data Structures & AlgorithmsHard

How many contiguous windows of length 3 in 5 3 4 6 2 7 1 8 are STRICTLY monotone (strictly increasing or strictly decreasing)?

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

Correct answer: C. 1

A length-3 window is strictly monotone when both consecutive steps go the same strict direction. Counting only increasing windows misses the decreasing ones, and non-strict comparisons admit repeated values.

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

Exams that ask this topic