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]?
- A. 5
- B. 9
- C. 3
- 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
- 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"?
- Fractional knapsack, capacity 18 (items can be split). Items (weight, value): (6, 11), (5, 10), (3, 15), (6, 5). Using the greedy…
- Using the merge-sort inversion-count technique (count, during each merge step, how many left-half elements are greater than the current…