Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the minimum number of elements to delete from [4, 9, 1, 6, 3, 8] so that the remaining elements have maximum minus minimum at most 3?

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

Correct answer: B. 3

Sort the values and keep the longest window whose span is at most D; deletions are the rest. The sorted order is what makes the window technique valid.

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

Exams that ask this topic