Example 1
Input
words = ["eat","tea","tan","ate","nat","bat"]
Output
[["eat","tea","ate"],["tan","nat"],["bat"]]
Loading CodeSprint...
/problems/group-anagrams
Group words that contain the same letters with the same frequencies. Return groups in the order their first member appears, and keep words inside each group in their original input order.
Implement this function and return the result. CodeSprint supplies each test case automatically.
groupAnagrams(words) → string[][]Input
words = ["eat","tea","tan","ate","nat","bat"]
Output
[["eat","tea","ate"],["tan","nat"],["bat"]]
Input
words = [""]
Output
[[""]]
Constraints
0 <= words.length <= 10,000 Each word contains lowercase English letters.