Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Two heaps are used to track the minimum and maximum of a sliding window of size 3 over [4, 8, 1, 9, 3, 7]. How many windows have a difference (max minus min) of at least 6?

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

Correct answer: D. 4

Evaluate each window's max and min and test the difference. Windows of size two would give a different count.

More Coding Interview Problems questions

Exams that ask this topic