#C14122. Word Frequency Counter
Word Frequency Counter
Word Frequency Counter
Given a string of words, possibly containing punctuation and varying cases, your task is to count the frequency of each unique word (case-insensitive) and output the results in a JSON format. A word is defined as a sequence of alphanumeric characters.
For example, for the input Hello, world!
, the correct output is {"hello": 1, "world": 1}
.
inputFormat
The input is provided via stdin as a single string. The string may contain spaces, punctuation, or even multiple lines.
outputFormat
The output should be the frequency dictionary in a JSON format printed to stdout. The keys (words) must be in lower case, punctuation should be ignored, and the keys should be sorted in alphabetical order.
## sampleHello world
{"hello": 1, "world": 1}