题解 | #最长回文子串#
最长回文子串
https://www.nowcoder.com/practice/12e081cd10ee4794a2bd70c7d68f5507
a = list(input())
b = list(reversed(a))
dp = [[0 for i in range(len(a)+1)] for j in range(len(b)+1)]
ml = 0
for i in range(len(a)):
for j in range(len(b)):
if a[i] == b[j]:
dp[i+1][j+1] = dp[i][j] + 1
%我的评价是神之一笔,判定正反序相同子串是同一序列就可以了
if dp[i+1][j+1] > ml and abs(j - (len(a)-1-i))+1 == dp[i+1][j+1]:
ml = dp[i+1][j+1]
print(ml)
