Data Structures & AlgorithmsModerateProduct-company MCQ pattern

What is the length of the longest strictly increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7]?

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

Correct answer: A. 4

For example 3, 4, 6, 7 (or 2, 4, 6, 7, or 1, 4, 6, 7), length 4. Taking 3, 10, 20 (length 3) shows why a greedy 'jump to the next bigger value' fails.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic