Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

The array [5, 1, 6, 2, 7, 3, 8] must be made strictly increasing by deleting as few elements as possible. How many deletions are needed?

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

Correct answer: C. 3

Deletions needed equal n minus the length of the longest strictly increasing subsequence. The LIS here has length 4, so the deletions count is 3. Reporting the LIS length itself answers a different question.

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

Exams that ask this topic