โœ๏ธ

Group Anagrams

Medium๐Ÿท๏ธ Hashing๐Ÿ“‚ Hash Maps & Sets
๐Ÿงฉ The problem

Group words that are anagrams of each other. Return the groups sorted: words inside each group alphabetically, and groups by their first word.

Examples

  • ["eat","tea","tan","ate","nat","bat"] โ†’ [["ate","eat","tea"],["bat"],["nat","tan"]]

๐ŸŽฏ Aim for: O(n ยท k log k) time for n words of length k

โœ๏ธ Write your solution

Pick a language, press Run to try it, then Run tests to check it against every test case โ€” just like a coding interview.

โ† All practice problems