Edit Distance Problem
Solve an interesting example taken from the SPOJ online contest based on strings and dynamic programming.
We'll cover the following...
Problem statement
You are given two strings str1
and str2
. The operations listed below can be performed on str1
. Find the min number of edits (operations) required to convert str1
to str2
.
- Insert
- Remove
- Replace
All the above operations are of equal cost.
Let us look at the following two examples:
- We have two strings, str1 = cat and str2 = cut. To convert cat to cut, we just need to