题解 | #密码截取#运行速度慢,哪位大神帮忙优化一下
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
st = input() a = [] for i in range(len(st)): for j in range(len(st)): if j >= i: if st[i:j+1] == st[i:j+1][::-1]: a.append(len(st[i:j+1])) print(max(a))
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
st = input() a = [] for i in range(len(st)): for j in range(len(st)): if j >= i: if st[i:j+1] == st[i:j+1][::-1]: a.append(len(st[i:j+1])) print(max(a))
相关推荐