Data Structures & AlgorithmsVery hardProduct Company SDE · CP practice

What is the Levenshtein edit distance (insert, delete, substitute all cost 1) between "DAABDB" and "BCDCEBDB"?

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

Correct answer: B. 4

DP: d[i][j] = min(d[i−1][j]+1, d[i][j−1]+1, d[i−1][j−1]+[s_i≠t_j]) → 4. The indel-only distance 6 forbids substitution.

More Coding Interview Problems questions

Exams that ask this topic