Reppity
SRM 198 · 2004-06-12 · by Rustyoldman
Problem Statement
Given a
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.
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.
"ABCDEXXXYYYZZZABCDEZZZYYYXXX" Returns: 5
The example from above.
"abcdabcdabcdabCD" Returns: 6
"abcdab"+"cd"+"abcdab"+"CD"
"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy" Returns: 25
"againANDagainANDagainANDagainANDagainANDagain" Returns: 21
"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" Returns: 24
Submissions are judged against all 46 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Reppity with a public method int longestRep(string input) · 46 test cases · 2 s / 256 MB per case