Pytho题解 | #查找两个字符串a,b中的最长公共子串#
查找两个字符串a,b中的最长公共子串
https://www.nowcoder.com/practice/181a1a71c7574266ad07f9739f791506
while True:
try:
s1 = input()
s2 = input()
if len(s1) < len(s2):
a = s2
s2 = s1
s1 = a
max_l = 0
ans = ''
for i in range(len(s2) - 1):
for j in range(i + 1, len(s2) + 1):
if s1.find(s2[i:j]) != -1:
cur = len(s2[i:j])
if cur > max_l:
max_l = cur
ans = s2[i:j]
print(ans)
except:
break

