import sys
s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()
if len(s) > len(t):
s,t = t,s
i,res = 0,''
for j in range(len(s)):
while s[i:j+1] not in t and i <= j:
i += 1
if s[i:j+1] in t and j-i+1 > len(res):
res = s[i:j+1]
print(res)
滑动窗口最优解



京公网安备 11010502036488号