delete mininum characters to make string as panlindrome# JobHunting - 待字闺中C*n2014-07-28 07:071 楼delete minimum characters to make string as palindromeany good idea?
p*r2014-07-28 07:072 楼这是一道DP的算法题对长度为n的字符串str, 求maxp(str)1. 如果str[0] == str[n-1], maxp(str) = 2+maxp(str[1 .. n-2])2. 如果str[0] != str[n-1], maxp(str) = max(maxp(str[0 .. n-2]), maxp(str[1 .. n-1]))3. 循环递归 1, 2用递归的话算法复杂度是O(2^n)但是中间有很多运算是重复的,我们定义一个二维数组记录子字符串str[i .. j]的maxp算法复杂度变成O(n^2)