Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["eat","tea","ate"],["tan","nat"],["bat"]]
Explanation: "eat", "tea" and "ate" all use the letters a, e and t, so they form one group. "tan" and "nat" share the letters a, n and t. "bat" matches nobody, so it is a group on its own.
Example 2
Input: strs = [""]
Output: [[""]]
Explanation: The empty string is the only word, so it forms one group by itself.
Example 3
Input: strs = ["a"]
Output: [["a"]]
Explanation: The only word forms its own group.
Two strings are anagrams iff they have the *same letter frequencies*. Encoding each string as a length-26 count tuple gives a canonical key in `O(k)` time, beating the sort-based approach's `O(k log k)`.
Run checks all cases above. Submit evaluates all test cases.