Data Structures & AlgorithmsVery hardProduct Company SDE · Amazon/Microsoft-style OA

What is the length of the longest common subsequence of "ACEACCEBD" and "DBEADDEA"?

  1. A. 6
  2. B. 4
  3. C. 2
  4. D. 3

Correct answer: D. 3

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 3. The edit distance between the same strings is a different quantity, 6.

More Coding Interview Problems questions

Exams that ask this topic