欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt

程序员文章站 2024-03-15 22:57:00
...

Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt

def lon(s):
    outString = ""
    while len(s) > len(outString):
        indLen = len(outString)
        temp = s[: indLen]
        for ch in s[indLen:]:
            temp += ch
            print(temp)
            if temp == temp[::-1]:
                outString = temp if len(temp) > len(outString) else outString
        s = s[1:]
    return outString
lon('okllkk')