Class Name: StringCompressor
Method Name: compress
Implement a class StringCompressor, which contains a method compress. The
method takes a String as a parameter and replaces all successively duplicated
letters in the String with a number that is the number of duplications followed
by the repeated character. The method returns this resulting String.
The method signature is (be sure your method is public):
String compress(String toCompress)
TopCoder will ensure the following:
- toCompress is a String of at most 100 letters. Each character is a lowercase
or capital letter ('a' - 'z' or 'A' - 'Z').
-This compressor is case sensative. 'A' is a different character than 'a'.
-Single letters (its neighbors are not duplicates of itself) are left alone.
"AAAABBBBCDDDDDD" compresses to "4A4BC6D"
"SDFJaAAAAaaaass" compresses to "SDFJa4A4a2s"
"AAAAAAAAAAAf" compresses to "11Af"