#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param A string字符串
# @return int整型
#
class Solution:
def getLongestPalindrome(self , A: str) -> int:
# write code here
ret = 1
for i in range(A.__len__()):
ret = max(self.palindrome(A, i, i), self.palindrome(A, i, i+1), ret)
return ret
@staticmethod
def palindrome(s, l, r):
while l >= 0 and r < s.__len__():
if s[l] == s[r]:
l -= 1
r += 1
else:
break
return r - l + 1 - 2