Edit Distance 题解
Last updated
Was this helpful?
Last updated
Was this helpful?
题目来源:
> 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, DP[i][j] 表示word1[0:i-1] 与 word2[0:j-1]的编辑距离。 w(del), w(ins), w(sub) 分别是删除,插入,替换(substitute)的权重。
关于更多编辑距离的算法及应用可参考 。