题解 | #密码截取#
密码截取
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1?tpId=37&tqId=21255&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
# 感觉有点像最长回文子串 s = input() n = len(s) def expand(s, i, j): while i >= 0 and j < n and s[i] == s[j]: i -= 1 j += 1 return j - i - 1 ans = 0 for i in range(n): ans = max(ans, expand(s, i, i)) ans = max(ans, expand(s, i, i+1)) print(ans)