Group Anagrams

easy
Unit 4 · Dicts0/3 to milestone

Two words are anagrams if they use exactly the same letters, like "listen" and "silent".

Implement group_anagrams(words) that groups the words into anagram families.

Requirements

  • Return a list of groups, where each group is a list of words.
  • Keep words in each group in the order they first appeared.
  • Order the groups by when their first word appeared.

Example

group_anagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
# [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]
#dicts#strings3 visible + 2 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Group Anagrams · TechGradify