Group Anagrams
Put words that are anagrams of each other into the same group.
The problem
Implement Solution.groupAnagrams(words). Two words are anagrams when one can be made by rearranging the letters of the other, using every letter exactly as many times. Return the words split into groups so that two words are in the same group exactly when they are anagrams. Keep every word, including repeated words and empty strings. The order of the groups, and of the words inside a group, does not matter.
Starter code
class Solution:
def groupAnagrams(self, words: list[str]) -> list[list[str]]:
passPublic examples
words = ["eat", "tea", "tan", "ate", "nat", "bat"]gives[["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]words = ["", "", "a"]gives[["", ""], ["a"]]words = ["abc", "abd"]gives[["abc"], ["abd"]]
One thought at a time.
