pku3356AGTC(做的最少修改动作,动态规划)

4228K 0MS GCC 568B 2009-01-09 11:00:31

注意:这道题目是多case。。。。害我在这上面wrong了n次。

数组best[i][j],第一个字符串前i位和第二个字符串前j位能做到的最优值。

分析:

1)a[i]==b[j],best[i][j]=best[i-1][j-1];

2)  a[i]!=b[j],best[i][j]=min(best[i-1][j-1],best[i-1][j],best[i][j-1])+1;

第一个元素:修改操作。第二个元素:删除操作。第三个元素:添加操作。

代码如下:

 

Code
原文地址:https://www.cnblogs.com/pandy/p/1372406.html