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]?
- A. 6
- B. 2
- C. 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
- How many subsets (by index, so equal values at different positions count separately) of [9, 8, 8, 2, 2, 1, 5, 1, 6] sum to exactly 12?
- What is the length of the longest palindromic subsequence (not substring) of "BBCABABC"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [15, 1…
- How many subsets (by index, so equal values at different positions count separately) of [1, 3, 3, 5, 1, 5, 9, 5, 1] sum to exactly 11?
- What is the length of the longest palindromic subsequence (not substring) of "BBBBEBBAA"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [17…