Given 2 Strings, our task is to check overlapping of one string’s suffix with prefix of other string.
Input : test_str1 = "Gfgisbest", test_str2 = "bestforall" Output : best Explanation : best overlaps as suffix of first string and prefix of next. Input : test_str1 = "Gfgisbest", test_str2 = "restforall" Output : '' Explanation : No overlapping.
In this, we increment the first list and slice till list end and keep comparing with the prefix substring of other string using startswith(). In this, the word that occurs at end of string is compared with once with prefix of 2nd string.
The original string 1 is : Gfgisbest The original string 2 is : bestforall Overlapped String : best
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course