The problem is so simple. You are given a string and you have to remove all duplicate characters from the string and print the list of unique characters occurring in the input string, along with the number of occurrences each.
The input starts with an integer T ( 1 <= T <= 5 ) denoting the number of testcases. Every testcases contain a non-empty string s ( 1 <= |s| <= 100000 )
For each case print the case number in the format “Case #X:” where ‘X’ should be replaced with case number. then print a new line. Then sequence of ordered pairs, separated by new lines. The first element of the pair must be a character from the input string. The second element must be the number of occurrences that particular character appeared in that string. The elements in each pair are to be separated by space. The characters are to appear in the order in which they were contained in the input string. See the sample I/O for better explanation.
2 book madam
Case #1: b 1 o 2 k 1 Case #2: m 2 a 2 d 1
Login to submit