Dynamic programming

20.2 - String edit distance


The edit distance between two strings, also known as the Levenshtein distance, is determined by how many operations (adding, removing, or changing a character) is needed to go from one to another.

Your task is to create a program which takes two lines of string as the input and then outputs the edit distance.

Sample input 1

kitten
sitting

Sample output 1

3

Sample input 2

banana
ananas

Sample output 2

2
#include <iostream> #include <string> int main() { }