4

Count Frequency

Difficulty: EASY
Avg. time to solve
15 min
Success Rate
85%

Problem Statement
Suggest Edit

You are given a string S of length N, you need to find the frequency of each of the characters from ‘a’ to ‘z’ in the given string.

Note:

1. All the characters in the string are in lowercase.
2. Length of the strings will always be greater than zero.
Input Format:
The first line of the input contains an integer T denoting the number of test cases.
The first and the only line of each test case contains the string S.
Output Format:
The only line of output of each test case should contain 26 space-separated integers, where the ith integer represents the frequency of the ith character. 
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 100
1 <= len(S) <= 10^4    
Time Limit: 1sec
Sample Input 1:
1
abaaba
Sample Output 1:
4 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
Explanation for Sample Input 1:
The frequency of ‘a’ is 4 and the frequency of ‘b’ is 2.
Sample Input 2:
2
bbcccaaaa
z
Sample Output 2:
4 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 
Explanation for Sample Input 2:
For the first input, the frequency of ‘a’ is 4, ‘b’ is 2 and ‘c’ is 3.
For the second input, the frequency of ‘z’ is 1.
Want to solve this problem? Login now to get access to solve the problems