AcWing 779. 最长公共字符串后缀 - Python3
原题链接
困难
作者:
KYCygni
,
2021-03-20 09:59:59
,
所有人可见
,
阅读 271
Python3 代码
while True:
n = int(input())
if n == 0:
break
s = [""] * 200
s_len = n
mlen = 200
for i in range (n):
s[i] = input()
if mlen > len(s[i]):
mlen = len(s[i])
is_success = True
for j in range (mlen):
ms2 = s[0][len(s[0]) - 1 - j]
for k in range (1, s_len):
if s[k][len(s[k]) - 1 - j] != ms2:
is_success = False
break
if not is_success:
print (s[0][len(s[0]) - j:])
break
if is_success:
print (s[0][len(s[0]) - mlen:])