Data Structures & AlgorithmsVery hard

How many contiguous windows of length exactly 4 in 6 2 5 9 4 7 3 satisfy (maximum − minimum) ≤ 3?

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

Correct answer: C. 0

Each fixed window of length 4 is checked on its own max and min, and the bound is inclusive. Using a strict bound, changing the window length, or counting the complement each give other values.

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

Exams that ask this topic