




In Meta Messenger, you are given a list of lowercase strings and need to group together strings that are anagrams of each other. Two strings are anagrams if they contain the same characters with the same frequencies, possibly in a different order.
Write a function that returns a list of groups, where each group contains strings from the input that are anagrams of one another. The order of groups does not matter, and the order of strings within each group does not matter.
strs, a list of stringsExample 1
strs = ["eat", "tea", "tan", "ate", "nat", "bat"][["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]Example 2
strs = [""][[""]]1 <= len(strs) <= 10^40 <= len(strs[i]) <= 100strs[i] contains only lowercase English lettersstrs = ["eat", "tea", "tan", "ate", "nat", "bat"]Output[["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]WhyThe strings "eat", "tea", and "ate" share the sorted key "aet"; "tan" and "nat" share "ant"; "bat" stands alone.strs = [""]Output[[""]]WhyThe empty string has an empty sorted key, so it forms a single group.strs = ["a"]Output[["a"]]WhyA single string is always its own anagram group.1 <= len(strs) <= 10^40 <= len(strs[i]) <= 100strs[i] contains only lowercase English lettersOrder of groups does not matterOrder of strings within each group does not matterdef group_anagrams(strs):