You are given a particular string S, which contains only lowercase English alphabets. Your task is to calculate all the occurrences of the character and print the character in the order in which it appears in the string S followed by the number of occurrences.
Each character should appear only once in the output.
Example
Consider S = abab. You must determine the new string as given in the problem statement:
So final string would be a2b2.
Function description
Complete the CountOccurrences function provided in the editor. This function takes the following 1 parameters and returns desired string:
S: Represents the given string.
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output format
For each test case, print the output in a new line.
Constraints
1≤T≤1000
1≤|S|≤1000 where S denotes the length of the string.
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
In this case ‘o’ occurs only one time, ‘c’ occurs 3 times and so on.