Edit Distance

题目描述

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)

You have the following 3 operations permitted on a word:

a) Insert a character b) Delete a character c) Replace a character

解题方法

这种求最大最小的情况,一般都是DP

注意点

  • 当word1[i-1] == word2[j-1]时,不需要replace,但是依然要和insert和delete的比较

Solution

Reference