回文是什么,回文是正着读和反着读都是一样的字符叫着回文。
如 ‘aba’,‘aa’,‘b’,这些都是回文

class Solution:
def longestPalindrome(self,s: str) -> str:
n = len(s)
dp = [[False] * n for _ in range(n)]
ans = ""
for l in range(n):#l代表1个字符串,2个字符串,3个字符串
for i in range(n):
j = i+l
if j >= len(s):
break
if l == 0:
dp[i][j] = True
elif l ==1:
dp[i][j] = (s[i]==s[j])
else:
dp[i][j] = (dp[i+1][j-1] and s[i]==s[j])
if dp[i][j] and l+1>len(ans)
ans = s[i:j+1]
return ans








![LeetCode-805.保持城市天际线 C/C++实现 超详细思路及过程[M]](https://img-blog.csdnimg.cn/24a8adb657b5475491f87792460550b6.png#pic_center)







![BUUCTF [GUET-CTF2019]KO 1](https://img-blog.csdnimg.cn/a69c4c8e014247e989276f5ae7139b1b.png)


