class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
for x in range(len(s)-1,0,-1):
for i in range(len(s)-x):
str1 = s[i:i+x+1]
if str1==str1[::-1]:
return str1
return s[0]
目录一、题目描述二、题解三、源码一、题目描述二、题解三、源码class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ for x in range(len(s)-1,0,-1): for i in range(len(s)-x