题解 | #最长回文子串#

最长回文子串

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


全部评论

相关推荐

移动云能力 苏小妍 总包多3w左右
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务