题解 | #密码截取#

密码截取

https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1

def spread(left,right,word):
    while left>=0 and right<=len(word)-1 and word[left]==word[right]:
        left-=1
        right+=1
    return len(word[left+1:right])

while True:
    try:
        res=0
        word=input()
        for i in range(len(word)):
            single=spread(i,i,word)
            if single>res:
                res=single
            ou=spread(i,i+1,word)
            if ou>res:
                res=ou
        print(res)
    except:
        break

全部评论

相关推荐

点赞 评论 收藏
分享
不知名bang:感觉三个项目可以融在一起,比如上层是用手写的epoll,然后到tcp聊天层,然后你写了一个后台监控(不过我也不懂c++,但是感觉写一个大项目比三个小项目要好)
我的求职进度条
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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