Data Structures & AlgorithmsHardProduct Company SDE · CP practice
What is the length of the longest common subsequence of "DADEEDEE" and "CCDDDBC"?
- A. 9
- B. 3
- C. 5
- D. 6
Correct answer: B. 3
DP table d[i][j] = d[i-1][j-1]+1 on a match, else max of the two neighbours. LCS length = 3. (Edit distance is 6, a different quantity.)
More Coding Interview Problems questions
- What is the length of the longest palindromic subsequence (not substring) of "BDDDACBBD"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [4, 7…
- 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"?