Skip to content
← Back to the archive

20 August 2026

Anagram Groups

Medium Dictionaries

Sort scrambled words back into their anagram families.

Given a list of lowercase words, group every word with the others that are its anagrams (same letters, any order). Return the groups as a list of lists, each group listing its words in the order they first appeared, and the groups themselves ordered by each group's first appearance.

Constraints

  • 0 <= len(words) <= 300
  • Each word contains only lowercase English letters
  • 1 <= len(word) <= 50 for every word

Function signature

def anagram_groups(words):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.