递归算法
def lps(string, i, j):
if i == j:
return 1
if i > j:
return 0
if string[i] == string[j]:
return lps(string, i+1, j-1) + 2
return max(lps(string, i+1, j), lps(string, i, j-1))
def main():
string = 'abcdefc'
n = len(string)
res = lps(string, 0, n-1)
print res
if __name__ == '__main__':
main()