题解 | #最长回文子串#

最长回文子串

https://www.nowcoder.com/practice/b4525d1d84934cf280439aeecc36f4af

暴力解法

class Solution:
    def getLongestPalindrome(self, A: str) -> int:
        max_len = 1
        for start_index in range(0,len(A)):
            end_index = start_index
            while end_index < len(A):
                group_now =  A[start_index:end_index+1]
                if group_now == group_now[::-1]:
                    max_len = max(max_len,len(group_now))
                end_index +=1

        return max_len


全部评论

相关推荐

05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
我:“加班需要有加班工资。”&nbsp;hr:“为什么?”&nbsp;哈哈哈哈哈哈哈离大谱
juntenor:你确实太理想化了,对社会不了解呀。这个和HR没有关系,这是国内特色,不然怎么还会有外包就这种逆天的存在呢。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务