Given an array of strings, group the anagrams together. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
For example, given the input:
["eat", "tea", "tan", "ate", "nat", "bat"]
One possible output is:
[
["eat", "tea", "ate"],
["tan", "nat"],
["bat"]
]
Your task is to write a function that takes an array of strings and returns a list of groups of anagrams. Each group can be in any order, and the groups themselves can be in any order.
Hint: Use a hashmap to help map sorted character sequences to the list of words that match them.
Note: March 5th is a reminder that sometimes, just as letters can be rearranged into new words, rearranging your approach with simple hashmaps can lead to elegant solutions in programming!