Group words by their letters
Given a list of lowercase words words, group together the words that are anagrams of each other: they use exactly the same letters, the same number of times, in any order. Return the groups as a list of lists. Every word goes in exactly one group, and a word that appears twice in the input appears twice in its group. The order of the groups, and of the words inside each group, does not matter.
Words may be empty strings. Aim for one pass over words.
Besides the tests, one large input (1,500 words) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
group_by_letters(["stop","pots","tops","opt","top","dog"])→[["stop","pots","tops"],["opt","top"],["dog"]]group_by_letters(["aab","abb","aba","bab"])→[["aab","aba"],["abb","bab"]]group_by_letters(["ab","ba","ab"])→[["ab","ba","ab"]]