Group Anagrams
MediumArrayStringHash MapSORTING
Given an array of strings strs, group the anagrams together.
Two strings are anagrams if:
- They contain the same characters
- The frequency of each character is the same
Return the grouped anagrams in any order.
## Constraints
- 1 ≤ strs.length ≤ 10⁴
- 0 ≤ strs[i].length ≤ 100
- strs[i] consists of lowercase English letters
## Example
Input: ["eat","tea","tan","ate","nat","bat"]
Output: [["eat","tea","ate"],["tan","nat"],["bat"]]
Examples
Example 1
Input: ["eat","tea","tan","ate","nat","bat"]
Output: [["eat","tea","ate"],["bat"],["tan","nat"]]