← 返回 citadel 的题目列表Word Frequency Counter
类型:online_judge
Problem
Implement word_frequency(text): given a string, return a dictionary mapping every word to its number of occurrences.
For this problem, a word is a whitespace-delimited token. Matching is case-sensitive, and punctuation attached to a token remains part of that token.
For example:
the cat sat on the mat
returns:
{"the": 2, "cat": 1, "sat": 1, "on": 1, "mat": 1}
Input Format
Standard input contains one line, text.
Output Format
Print words in order of first appearance, one per line as word count.
Constraints
text has length at most 10^6.
Example
Input:
the cat sat on the mat
Output:
the 2
cat 1
sat 1
on 1
mat 1
Example
Input