- 链接地址:https://blog.csdn.net/dzysunshine/article/details/116166560
- 链接标题:Leetcode-字符串_es, start = 0, 0 for end in range(len(s)): if s[en-CSDN博客
- 所属网站:blog.csdn.net
- 被收藏次数:4456
文章浏览阅读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
版权声明:本文发布于特牛网址导航 内容均来源于互联网 如有侵权联系删除