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 [30, 23, 21, 10, 23, 10, 30, 4, 13]?
- A. 3
- B. 2
- C. 4
- D. 5
Correct answer: A. 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
- What is the length of the longest common subsequence of "DADEEDEE" and "CCDDDBC"?
- What is the length of the longest palindromic subsequence (not substring) of "BDDDACBBD"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [4, 7…
- What is the length of the longest common subsequence of "ABCDBEBC" and "CECCBBAAD"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [17, 4…
- What is the length of the longest common subsequence of "ECCCCBADC" and "EBDBECB"?