Data Structures & AlgorithmsHardProduct Company SDE · CP practice

What is the length of the longest common subsequence of "ABCDBEBC" and "CECCBBAAD"?

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

Correct answer: D. 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 7, a different quantity.)

More Coding Interview Problems questions

Exams that ask this topic