TopcoderArchiveVisit Topcoder
SRM13 Jun 2001
SRM 5

StringCompressor

Problem statement, definition, constraints, and public examples.

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)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems