#C14384. String Frequency Counter
String Frequency Counter
String Frequency Counter
You are given a list of strings and your task is to count the frequency of each unique string while preserving the order in which they first appear. This problem is case-sensitive, meaning that uppercase and lowercase letters are treated as distinct characters.
For instance, given the list: ['apple', 'banana', 'Apple', 'banana', 'banana']
, the output should be:
apple 1
banana 3
Apple 1
The solution should read from standard input and write the result to standard output. There is no special separator between the key and its count other than a space. No additional formatting is required for the output.
inputFormat
The first line contains an integer n ((0 \le n \le 10^5)), representing the number of strings. Each of the following n lines contains a single non-empty string. The strings may contain any visible characters and are case-sensitive.
outputFormat
For each unique string (in the order of its first appearance), output a line with the string followed by its frequency count, separated by a space.## sample
5
apple
banana
Apple
banana
banana
apple 1
banana 3
Apple 1
</p>