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 [4, 7, 26, 4, 22, 7, 27, 27, 22, 12]?
- A. 12
- B. 4
- C. 5
- D. 8
Correct answer: B. 4
O(n²) DP: d[i] = 1 + max d[j] for j<i with a[j]<a[i]. Answer 4; allowing equal values would give 5.
More Coding Interview Problems questions
- 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"?
- What is the Levenshtein edit distance (insert, delete, substitute all cost 1) between "DAABDB" and "BCDCEBDB"?
- Problem: 7 servers are joined by cables one at a time. Count the connected groups at the end and how many cables were redundant (joined…
- What is the length of the longest common subsequence of "BDACDBED" and "DEEAAC"?