Skip to content

Group Anagrams ​

Group Anagrams — LeetCode

Given an array of strings, group together all the strings that are anagrams of each other.

Approach ​

I tried by Sorting the strings and using them as a key to the HashMap, and then combining all the values together. A better approach is to use a HashTable, and the occurrences marked on the array joined into a string is used as the HashMap key. So a key for string abbc would be 1,2,1,0,0,0....

Remarks ​