Accenture Coding Question | Frequency Count | CodeWindow

Frequency Count

Given a string, find the frequencies of each of the characters in it.
The input string contains only lowercase letters. The output string should contain a letter followed by its frequency, in the alphabetical order (from a to z).

Input specification:
Input 1: The input string.

Output Specification:
Return a string representing the frequency counts of characters in the input string.

Example 1:
Input 1: babdc

Output: a1b2c1d1
Explanation:
In the input string, ‘a’ appears once, ‘b’ appears twice, ‘c’ and ‘d’ appear once.

Solution in Python 3:

Alternative Method

Solution in C :

Solution in C++ :

Solution in JAVA :

Output:

Recent Posts
Pages