Levenshtein Distance

Compute the Levenshtein distance between two strings.

Statement

Given two strings, compute the Levenshtein distance between them.

The Levenshtein distance, LDLD, is a measure of the difference between two strings, s1s_1 and s2s_2. It is the minimum number of deletions, insertions, or substitutions required to transform s1s_1 into s2s_2. It is also known as the edit distance.

Examples

Let’s see a few examples below:

  • If s1=ants_1= ant ...