Leetcode-字符串_es, start = 0, 0 for end in range(len(s)): if s[en-CSDN博客

网站介绍:文章浏览阅读200次。Leetcode-字符串1.最长回文子串1.最长回文子串5. 最长回文子串难度:【中等】方法:使用中心扩展法遍历每一个字符串,分两种情况进行中心扩展,一种为奇数,一种为偶数,如果两边字母相同,就继续扩展;如果不相同就停止扩展,对所有满足要求的长度求出最大值,得到最终答案。代码如下:class Solution: def expandAroundCenter(self, s, left, right): while left >= 0 and right < _es, start = 0, 0 for end in range(len(s)): if s[end] in record:#出现过 start