You are given a string ‘S’ of length ‘N’. You have to return all the characters in the string that are duplicated and their frequency.
N = 5
S = ‘GEEK’
ANSWER:- The answer should be [(‘E’,2)] because ‘E’ is the only character that is duplicated and has frequency 2.
Input Format :
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of every test case contains an integer ‘N’ denoting the length of the string.
The next line of every test case contains a string ‘S’ denoting the string given.
Output Format :
For each test case, return the duplicate characters in the string S and their frequency.
The output of each test case should be printed in a separate line.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 5
1 <= N <= 10^5
Time Limit = 1 sec
Sample Input 1 :
Sample Output 1 :
Explanation for Sample Output 1 :
In the first test case, the character ‘P’ has frequency 2 and is the only duplicate character in the string.
In the second test case, the character ‘A’ has frequency 3 and the character ‘N’ has frequency 2.
Sample Input 2 :
Sample Output 2 :