Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional

Strings a = "accca" and b = "bcbb". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein distance). What is the edit distance between a and b?

  1. A. 5
  2. B. 4
  3. C. 7
  4. D. 1

Correct answer: B. 4

The DP table gives 4. The insertion–deletion distance (no substitution) gives 7, which overcounts substitutions.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic