Group Anagrams
Medium
Strings
Hash Table
Sorting
Given an array of strings, group the anagrams together.
Input: comma-separated strings
Output: groups on separate lines, words comma-separated within each group, sorted alphabetically
Constraints
1 <= strs.length <= 10000
0 <= strs[i].length <= 100
strs[i] consists of lowercase English letters.
Examples
Example 1:
Input: eat,tea,tan,ate,nat,bat
Output:
Example 2:
Input:
Output:
Hints
Use sorted string as hash key.
A dictionary/map groups anagrams.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console