Calculate Long Count
You are given a string S. Write a program to find the length of the longest substring which occurs at least two times in it. Occurences can intersect.

Examples:
If the string is "wgyckaycka", then the program should return 4. The possible longest substring is ycka and the length is 4. It occurs twice in the given string.

Business Rules
String should contain only lowercase Latin letters.If not, display -1.
Maximum length of the string should be 50. Else display "Size of the string is too large".    
     
Input Format
One line containing a string S consisting of lowercase Latin letters.
Output Format
Output one integer which is the length of substring

Sample Input 1
wgyckaycka
Sample Output 1
4

Sample Input 2
youaregivenastringswriteaprogramtofindthelengthofthestring
Sample Output 2
Size of the string is too large

Sample Input 3
C++
Sample Output 3
-1



Function specification is the following for C#, Java and C++.
Name:- CalculateLongCount(C#)/calculateLongCount(Java,C++)
Return Type:- int
Parameter(s):- string s

Function specification for C is the following.
Name:- calculateLongCount
Return Type:- int
Parameter(s):- char* s;

No comments: