Group Anagrams
You are given an array of strings strs. Group together the words that are anagrams of each other (they use the same letters, each the same number of times), and return the list of groups.
Every word belongs to exactly one group. If a word appears several times, each copy goes into its group. You may return the groups in any order, and the words inside each group in any order.
Constraints
1 <= strs.length <= 10^40 <= strs[i].length <= 100strs[i]contains lowercase English letters only (it may be the empty string).
Examples
Example 1
Input: strs = ["listen","silent","enlist","google","gogole","cat","act"] Output: [["listen","silent","enlist"],["google","gogole"],["cat","act"]]
listen, silent and enlist use the same six letters; google and gogole match; cat and act match. Groups, and the words inside them, may come in any order.
Example 2
Input: strs = [""] Output: [[""]]
The empty string forms a group of its own.
Example 3
Input: strs = ["a"] Output: [["a"]]
JavaScript you'll use: Map and Set Strings and characters Sorting and comparators
/**
* @param {string[]} strs
* @return {string[][]}
*/
function groupAnagrams(strs) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.