题解 | #查找两个字符串a,b中的最长公共子串#
查找两个字符串a,b中的最长公共子串
http://www.nowcoder.com/practice/181a1a71c7574266ad07f9739f791506
两遍遍历,数组查找
while True:
try:
s1= input()
s2= input()
if len(s1)> len(s2):
s1,s2 = s2,s1
length=0
for i in range(len(s1)):
for j in range(i+1,len(s1)+1):
if s1[i:j] in s2 and (j-i)>length:
length=j-i
res = s1[i:j]
print(res)
except:
break