Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Group Anagrams

XPChallenge Points: 20
levelLevel: Medium

You are given a list of words words.
Put together the words that contain exactly the same letters, even if the letters are in a different order.
Return a list of these groups in any order.

Example 1:

Input: words = ["listen","silent","enlist","stone","tones","hello"]

Output: [["hello"], ["listen","silent","enlist"], ["stone","tones"]]

Explanation:

•"listen", "silent", and "enlist" share the same letters. • "stone" and "tones" share the same letters. • "hello" has no other match. _____________________________

Example 2:

Input: words = ["loop","pool","polo","top"]

Output: [["top"], ["loop","pool","polo"]]

Explanation:

•"loop", "pool", "polo" are anagrams of each other. •"top" stands alone.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result