There are two words
word2, you have to find the minimum number of operations required to convert
You are allowed to use the following 3 operations on a word:
- Insert a character
- Delete a character
- Replace a character
word1 = "almost" word2 = "algomonster"
almost -> algmost (insert 'g') algmost -> algomost (insert 'o') algomost -> algmonst (insert 'n') algomonst -> algomoste (insert 'e') algomoste -> algomoster (insert 'r')
word1 = "intention" word2 = "execution"
intention -> inention (remove 't') inention -> enention (replace 'i' with 'e') enention -> exention (replace 'n' with 'x') exention -> exection (replace 'n' with 'c') exection -> execution (insert 'u')
Try it yourself
Loading full content...