Medium · Strings
Group anagrams
Given an array of lowercase words strs, return the words grouped so that each group holds exactly the words that are anagrams of one another; the groups, and the words inside each group, may be in any order.
Examples
Example 1
["eat","tea","tan","ate","nat","bat"]Output: [["eat","tea","ate"],["tan","nat"],["bat"]]
Example 2
["abc","cba","xyz"]Output: [["abc","cba"],["xyz"]]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.