Data Structures & AlgorithmsModerateTCS NQT · Infosys

What is the minimum number of elements you must DELETE from [9, 4, 7, 2, 10, 3, 8, 11, 5] (the rest keep their order) so that the remaining array is strictly increasing?

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

Correct answer: B. 5

The kept elements form a strictly increasing subsequence, so the minimum deletions is n minus the longest strictly increasing subsequence. Counting elements that are out of place with respect to their neighbours gives a different number.

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

Exams that ask this topic