Group anagrams
MediumGiven a list of words, group the anagrams together.
Remember, an anagram is a word that is a rearrangement of all the letters of another word.
For example, given
["eat", "tea", "tan", "ate", "nat", "bat"]
Your function should return groups like:
[["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]
The order of the groups doesn't matter. The order of words inside a group doesn't matter either.
The starter code works on that example. Try
"aab" and "abb" before you trust it.Try it first
Solution
7 Essential DSA in the AI era Coding Interview Problems
Master DSA in the AI era by trying the coding challenges below.
- 1.Count occurrencesEasy
- 2.Fix the default listEasy
- 3.Move zeroesEasy
- 4.Is subsequenceEasy
- 5.First unique characterEasy
- 6.Group anagramsMedium
- 7.Climb stairsEasy
