Input: ramisgood
goodforall.
Output: good.
string1 = input()
string2 = input()
result = ""
len1, len2 = len(string1), len(string2)
for i in range(len(string1)):
for j in range(len(string2)):
local_ind = 0
max_match = ''
while ((i + local_ind < len(string1)) and (j + local_ind < len(string2)) and string1[i + local_ind] == string2[
j + local_ind]):
max_match += string2[j + local_ind]
local_ind += 1
if len(max_match) > len(result):
result = max_match
print(result)
Comments
Leave a comment