Problem 2512. longest common semi-substring

Finding longest common substring is a common problem in string processing. This problem is a variant of that.

Two strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.

Example:

str1 = 'party';
srt2 = 'pure';

Here, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.