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 [17, 4, 26, 25, 21, 7, 23, 11, 9]?

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

Correct answer: C. 3

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

More Coding Interview Problems questions

Exams that ask this topic