题解 | #最长回文子串#
最长回文子串
https://www.nowcoder.com/practice/b4525d1d84934cf280439aeecc36f4af
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param A string字符串 # @return int整型 #双指针,一个表示起点,另一个表示步长,步长需后期修正特殊情况 class Solution: def getLongestPalindrome(self , A: str) -> int: # write code here count=[] for i in range(len(A)): for j in range(1,len(A)-i+1): if A[i:i+j]==A[i:i+j][::-1]: count.append(j) else: continue return max(count)