#K53067. K-Frequent Characters Count
K-Frequent Characters Count
K-Frequent Characters Count
You are given an integer n which represents the length of a string s, the string s itself, and an integer k. Your task is to determine the number of distinct characters in s that occur exactly k times.
Input Format: The input begins with an integer T on a new line representing the number of test cases. For each test case, there are three lines: the first line contains the integer n, the second line contains the string s, and the third line contains the integer k.
Output Format: For each test case, output a single integer on a new line corresponding to the count of characters in s that appear exactly k times.
Examples:
Input: 3 6 aabbcc 2 4 abcd 1 5 aaaaa 3</p>Output: 3 4 0
inputFormat
The first line of input contains an integer T denoting the number of test cases. Each test case consists of three subsequent lines:
- An integer n representing the length of the string s.
- A string s consisting of lowercase/uppercase letters.
- An integer k indicating the frequency to check.
Note: The value n is provided for informational purposes and may be ignored during processing.
outputFormat
For each test case, print the count of characters in the string s that appear exactly k times. Each answer should be printed on a separate line.
## sample3
6
aabbcc
2
4
abcd
1
5
aaaaa
3
3
4
0
</p>