Prefix Suffix
write a program to check the overlapping of one string's suffix with the prefix of another string.
Sample input 1
ramisgood
goodforall
Sample output 1
good
Sample input 2
finally
restforall
Sample output 2
No overlapping
f_str = input()
s_str = input()
s = "No overlapping"
if len(f_str) > len(s_str):
i = len(s_str)
else:
i = len(f_str)
while i > 0:
if f_str[len(f_str)-i:] == s_str[:i]:
s = s_str[:i]
break
i -= 1
print(s)
Comments
Leave a comment