#P2957. Moo Overlap Length
Moo Overlap Length
Moo Overlap Length
The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has recorded the exact wording of each moo as it goes out and returns. She is curious as to just how much overlap there is.
Given two strings consisting of lowercase letters (from the set a..z) with lengths in the range $1\leq L \leq 80$, determine the greatest number of characters of overlap between the two strings. A string is considered an overlap of two other strings if it is a prefix of one string and a suffix of the other string.
For example, consider the two moos below:
moyooyoxyzooo yzoooqyasdfljkamo
The last part of the first string overlaps with the first part of the second string with yzooo
, and the last part of the second string overlaps with the first part of the first string with mo
. The longest overlap is yzooo
whose length is 5.
POINTS: 50
inputFormat
The input consists of two lines. Each line contains a string (only lowercase letters: a-z) with a length between $1$ and $80$.
outputFormat
Output a single integer: the length of the longest overlap between the two strings.
sample
moyooyoxyzooo
yzoooqyasdfljkamo
5