TopcoderArchiveVisit Topcoder
SRM23 Aug 2001
SRM 25

FreqCounter

Problem statement, definition, constraints, and public examples.

Problem Statement

Class name: FreqCounter
Method name: getFreq
Parameters: String
Returns: String

Implement a class FreqCounter containing a method getFreq.  The method inputs a
String, counts the number of times each letter occurs in a String and returns a
String containing one of each character in the input String, followed the
number of times the character occurs in the input String. The characters in the
return string should be in the order they first appear in the input string.

Here is the method signature (be sure your method is public):
String getFreq(String input);

input will be between 1 and 50 letters (a-z, A-Z) in length, inclusive.

"Helloworld" returns "H1e1l3o2w1r1d1" because there is one capital H, there is
one lowercase e, there are three lowercase l's, etc...

Examples:
"abracadabra" returns "a5b2r2c1d1"
"zookeeper" returns "z1o2k1e3p1r1"
"kalamazoo" returns "k1a3l1m1z1o2" (That is the letter l followed by the number
one)
"aAaAa" returns "a3A2"

Definition

Class:
FreqCounter
Method:
getFreq
Parameters:
String
Returns:
String
Method signature:
String getFreq(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