Group Anagrams
Problem Given a list of strings, group together the ones that are anagrams of each other — strings with the same multiset of characters, regardless of order.
Input / Output
- Input: an array of strings
words(lowercase English letters). - Output: a list of groups, each containing all mutual anagrams. Group order and within-group order are unconstrained.
Constraints
- 1 ≤ n ≤ 10^4.
- Each string up to ~100 characters.
Example
["eat","tea","tan","ate","nat","bat"]→[["eat","tea","ate"],["tan","nat"],["bat"]].- Single-character and empty strings each group only with exact duplicates.
added …