Data Structures & AlgorithmsVery hardGoldman Sachs OA · LeetCode medium-hard
What is the length of the longest common subsequence of "ECAAEEDAE" and "BEEDEDD"?
- A. 3
- B. 5
- C. 7
- D. 4
Correct answer: D. 4
The DP table d[i][j] = d[i-1][j-1]+1 on a match, else max of the two neighbours, gives an LCS length of 4. The edit distance between the same strings is a different quantity, 7.
More Coding Interview Problems questions
- Using the merge-sort inversion-count technique (count, during each merge step, how many left-half elements are greater than the current…
- Fractional knapsack, capacity 16 (items can be split). Items (weight, value): (3, 8), (7, 6), (3, 8), (6, 8). Using the greedy…
- Fractional knapsack, capacity 15 (items can be split). Items (weight, value): (5, 14), (6, 9), (2, 9), (5, 13). Using the greedy…
- Fractional knapsack, capacity 12 (items can be split). Items (weight, value): (3, 12), (6, 9), (3, 13), (5, 9), (5, 6). Using the greedy…
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…