
In Meta Messenger search tooling, you are given a list of lowercase strings and need to group together strings that are anagrams of each other. Return the grouped strings in any order.
Two strings are anagrams if they contain the same characters with the same frequencies, but possibly in a different order.
Implement a function that takes strs, a list of strings, and returns a list of groups, where each group is a list of strings that are anagrams of one another.
strs: List[str]List[List[str]]Example 1
strs = ["eat", "tea", "tan", "ate", "nat", "bat"][["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]"eat", "tea", and "ate" share the same letters; "tan" and "nat" do as well.Example 2
strs = [""][[""]]Example 3
strs = ["a"][["a"]]1 <= len(strs) <= 10^40 <= len(strs[i]) <= 100strs[i] consists of lowercase English letters onlystrs = ["eat", "tea", "tan", "ate", "nat", "bat"]Output[["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]WhyStrings with identical sorted forms are grouped together: `aet`, `ant`, and `abt`.strs = [""]Output[[""]]WhyThe empty string has an empty sorted key and forms a single group.strs = ["abc", "bca", "cab", "xyz"]Output[["abc", "bca", "cab"], ["xyz"]]WhyThe first three strings are anagrams of each other, while `"xyz"` is not.1 <= len(strs) <= 10^40 <= len(strs[i]) <= 100strs[i] consists of lowercase English letters onlyThe order of groups does not matterThe order of strings within each group does not matterdef group_anagrams(strs):