#K15691. Categorizing Words by Length
Categorizing Words by Length
Categorizing Words by Length
In this problem, you are given a single line of input containing words separated by spaces. Your task is to group these words by their length. For each word length ( L ), you should output an array of words that have exactly ( L ) characters, preserving the order in which they appear in the input. The final output must be a JSON object where each key (as a string) represents a word length, and the corresponding value is an array of words with that length.
inputFormat
A single line containing a string of space-separated words. The input may be empty.
outputFormat
A JSON object in which each key (string) is a word length and its corresponding value is an array of words of that length.## sample
The quick brown fox jumps over the lazy dog
{"3": ["The", "fox", "the", "dog"], "5": ["quick", "brown", "jumps"], "4": ["over", "lazy"]}