题解 | #查找两个字符串a,b中的最长公共子串#
查找两个字符串a,b中的最长公共子串
http://www.nowcoder.com/practice/181a1a71c7574266ad07f9739f791506
def myfunc(x):
for j in range(len(a)-x+1):
if a[j:j+x] in b:
return(a[j:j+x])
return None
while True:
try:
a = input() #short
b = input() #long
if len(a) > len(b):
a, b = b, a
for i in range(len(a),0,-1):
result = myfunc(i)
if result != None:
break
print(result)
except:
break