可用滚动数组压缩空间,略
if s[i] = t[j] then
dp[i, j] := dp[i-1, j-1] // no operation required
else
dp[i, j] := min(
dp[i-1, j] + 1, // a deletion
dp[i, j-1] + 1, // an insertion
dp[i-1, j-1] + 1 // a substitution
)
加权的情况:
dp[i][j] := min( dp[i - 1][j] + delCost, min( dp[i][j - 1] + delCost, dp[i - 1][j - 1] + changeCost ) )
原文地址:http://blog.csdn.net/pandora_madara/article/details/39617373