Solution: Group Anagrams
Here's a detailed analysis on how to solve the group anagrams problem
We'll cover the following...
We'll cover the following...
Solution #1: Using sorting and hashing
First, this solution makes a copy of the array and sorts each string in the copy using the built-in sort() function of arrays. Then, it saves the sorted array into a HashMap called map. The key, in this case, is the sorted string, and the value is a vector of the indices of where it exists in the array. So, the hash table would have entries that look like:
eilsv <-> {7, 9}
abc <-> {1, 3}
Time complexity
Sorting one word takes ...