Data Structures & AlgorithmsHardProduct Company SDE · CP practice

A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [18, 16, 8, 17, 21, 23, 7, 20]?

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

Correct answer: C. 4

O(n²) DP: d[i] = 1 + max d[j] for j<i with a[j]<a[i]. Answer 4.

More Coding Interview Problems questions

Exams that ask this topic