![]() |
VOOZH | about |
In standard Edit Distance where we are allowed 3 operations, insert, delete, and replace. Consider a variation of edit distance where we are allowed only two operations insert and delete, find edit distance in this variation.
Examples:
Input : str1 = "cat", st2 = "cut"
Output : 2
We are allowed to insert and delete. We delete 'a'
from "cat" and insert "u" to make it "cut".
Input : str1 = "acb", st2 = "ab"
Output : 1
We can convert "acb" to "ab" by removing 'c'.
One solution is to simply modify the Edit Distance Solution by making two recursive calls instead of three. An interesting solution is based on LCS.
Implementation:
2
Complexity Analysis: