Group words by length
mediumDictionaries20 XP
Return a dictionary (JavaScript: object) that maps each word length to the list of words with that length, in their original order. Use the length as a key; in the expected answers it is written as a string, because JSON keys are strings.
Examples
- Input: words = ["hi", "cat", "hello", "yo", "dog"]Output: {"2": ["hi", "yo"], "3": ["cat", "dog"], "5": ["hello"]}
- Input: words = []Output: {}
Examples use JSON: true/false/null are True/False/None in Python.