Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: The array [5, 1, 6, 2, 7] must be made strictly increasing by deleting the fewest elements. What is the minimum number of deletions?

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

Correct answer: B. 2

Keeping the longest strictly increasing subsequence needs the fewest deletions, so the answer is the length minus the LIS length. Deleting the elements that are out of order locally can remove more than necessary.

More Coding Interview Problems questions

Exams that ask this topic