TopCoder problem "StringCompressor" used in SRM 5 (Division I Level One , Division II Level One)



Problem Statement

    
Class Name: StringCompressor
Method Name: compress
Parameters: String
Returns: String

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').

Note:
-This compressor is case sensative.  'A' is a different character than 'a'.
-Single letters (its neighbors are not duplicates of itself) are left alone.

Examples:
"AAAABBBBCDDDDDD" compresses to "4A4BC6D"
"SDFJaAAAAaaaass" compresses to "SDFJa4A4a2s"
"AAAAAAAAAAAf" compresses to "11Af"
 

Definition

    
Class:StringCompressor
Method:compress
Parameters:String
Returns:String
Method signature:String compress(String param0)
(be sure your method is public)
    

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=76

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=3004&pm=76

Writer:

Unknown

Testers:

Problem categories: