From neil.fraser.name:
How does one detect when two strings overlap? In the case below, the four-letter suffix of string 1 matches the four-letter prefix of string Sometimes there are several matches; finding the longest is not always straight forward. The naïve solution is to take ever smaller substrings of each string, compare them, then bail out when the first match is found.
Tagged: #algorithms #strings