Group anagrams
MediumHash maps · JavaScript
The task
Write groupAnagrams(words) that groups words that are anagrams of each other.
To make the answer predictable: sort the words inside each group alphabetically, and sort the groups by their first word.
Examples
- groupAnagrams(["eat","tea","tan","ate","nat","bat"]) returns [["ate","eat","tea"],["bat"],["nat","tan"]]
Your code runs in your browser, in a separate worker, and is never sent to us. Edit the function, then press Run tests. Your work is saved here as you type.
JavaScriptCtrl or Cmd + Enter to run