Problem Statement | |||||||||||||
Given a String, input, with up to 50 characters, find the length of the longest substring that appears at least twice (non-overlapping) in input. If no substring appears twice, non-overlapping, return 0. Strings are case sensitive, and only upper case letters and lower case letters are allowed in input. For example, in the string "ABCDEXXXYYYZZZABCDEZZZYYYXXX" the longest substring which appears at least twice is "ABCDE". These two substrings do not overlap so you would return 5. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | We are looking for subSTRINGS not subSEQUENCES. All of the elements of a substring appear consecutively in the original string. In other words, the substring can be formed from the original string by deleting zero or more characters from the begining and deleting zero or more characters from the end, but NO deletions from the middle are allowed. | ||||||||||||
Constraints | |||||||||||||
- | input will contain between 1 and 50 characters inclusive. | ||||||||||||
- | Each character in input will be between 'a' and 'z' inclusive or between 'A' and 'Z' inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|