Data Structures & AlgorithmsVery hardGoldman Sachs OA · LeetCode medium-hard

What is the length of the longest common subsequence of "ECAAEEDAE" and "BEEDEDD"?

  1. A. 3
  2. B. 5
  3. C. 7
  4. 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

Exams that ask this topic