FreeCareerPath
Build the PrimitiveMedium

Group Anagrams

Write `group_anagrams(words)` that groups the input into lists of mutual anagrams. Return a list of groups; order within a group and between groups does not matter. group_anagrams(["eat", "tea", "tan", "ate", "nat", "bat"]) -> [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]] Every solution here hashes each word to a key that anagrams share. Which key you pick is the interview: sorting each word costs O(k log k) per word, a character-count tuple costs O(k). Say which you chose and why.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Group Anagrams" are saved to your account — logging in takes a few seconds.

Group Anagrams — FreeCareerPath