题解 | #密码截取#

密码截取

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

n = input().strip() 
def palindrome(s, left, right): 
    while left >= 0 and right len(s) and s[left] == s[right]:
        left -= 1  
        right += 1  
    return s[left + 1:right]
res = "" 
for i in range(len(n)):
    s1 = palindrome(n, i, i)
    s2 = palindrome(n, i, i + 1)
    res = s1 if len(res) len(s1) else res
    res = s2 if len(res) len(s2) else res 
print(len(res))
全部评论

相关推荐

07-08 13:48
门头沟学院 C++
点赞 评论 收藏
分享
湫湫湫不会java:先投着吧,大概率找不到实习,没实习的时候再加个项目,然后把个人评价和荣誉奖项删了,赶紧成为八股战神吧,没实习没学历,秋招机会估计不多,把握机会。或者说秋招时间去冲实习,春招冲offer,但是压力会比较大
点赞 评论 收藏
分享
星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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