题解 | #最长回文子串#

最长回文子串

https://www.nowcoder.com/practice/12e081cd10ee4794a2bd70c7d68f5507

while True:
    try:
        s = input()
        res = ''
        for i in range(len(s)):
            start = max(0, i - len(res) - 1)
            tmp = s[start: i+1]
            if tmp == tmp[::-1]:
                res = tmp
            else:
                tmp = tmp[1:]
                if tmp == tmp[::-1]:
                    res = tmp
        print(len(res))
    except:
        break

全部评论

相关推荐

伤心了,精心准备了面试,结果还是被无情拷打,那我老实了
沉淀ing啊啊啊:这么快面试?
投递华为技术有限公司等公司10个岗位
点赞 评论 收藏
分享
在投简历的柠檬精很想...:可以明确说,问的东西几乎是简历上的东西。你写的确实有点模糊。面试可能会问你一些常用的通信的问题,差分信号走线之类的,单片机最小系统啥的,模电,数电,基本电源,buck,boost,ldo之类的吧。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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