Group Anagrams
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
Group Anagrams
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
Example 1
Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["eat","tea","ate"],["tan","nat"],["bat"]]
Example 2
Input: strs = [""] Output: [[""]]
Show hint
Use a hash map where key is sorted string (or character count) and value is list of anagrams. Group strings with same key.
Sign in to submit, save progress and mark problems as solved. You can still run your code.
Loading editor...
strs =
["eat","tea","tan","ate","nat","bat"]
Expected
[["eat","tea","ate"],["tan","nat"],["bat"]]