Answer to Question #211427 in Python for Ravichandrasekhar

Question #211427

The first line of the input will contain a string A.

The second line of the input will contain a string B.Output


The output should contain overlapping word if present else print "No overlapping".Explanation


For example, if the given two strings, A and B, are "ramisgood" "goodforall"

The output should be "good" as good overlaps as a suffix of the first string and prefix of next.

for input

correct

wrong


No overlapping
1
Expert's answer
2021-06-29T00:10:45-0400
a = str(input())
b = str(input())
answer = ""
len1, len2 = len(a), len(b)
for i in range(len1):
    match = ""
    for j in range(len2):
        if (i + j < len1 and a[i + j] == b[j]):
            match += b[j]
        else:
            if (len(match) > len(answer)):
                answer = match
                match = ""

print(answer)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS