Data Structures & AlgorithmsHardProduct Company SDE · CP practice
What is the length of the longest common subsequence of "BECCBACE" and "AEDDEA"?
- A. 6
- B. 1
- C. 2
- D. 3
Correct answer: C. 2
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 2. The edit distance between the same strings is a different quantity, 6.
More Coding Interview Problems questions
- Problem: Dijkstra's algorithm (array-based, pick the unvisited vertex with smallest tentative distance each round) computes shortest…
- Problem: Dijkstra's algorithm (array-based, pick the unvisited vertex with smallest tentative distance each round) computes shortest…
- What is the length of the longest common subsequence of "BBBEEBBA" and "BCDDDC"?
- What is the length of the longest common subsequence of "DCDCDAC" and "AABDCD"?
- What is the length of the longest common subsequence of "BAECBABDC" and "EEAEDAB"?
- What is the length of the longest common subsequence of "DCAEECCD" and "BEBEAADD"?