ASAPUtils Logo ASAPUtils
Week 1

Group Anagrams

Group Anagrams solved with a canonical key in one pass, with C++ and JavaScript solutions, both key strategies compared, and why the count signature beats sorting when the words are long.

The problem

Given an array of strings, group together all the strings that are anagrams of each other. Return the groups in any order.

["eat","tea","tan","ate","nat","bat"] -> [["eat","tea","ate"],["tan","nat"],["bat"]]

Related Problems