← 返回 roblox 的题目列表Group Anagrams
类型:online_judge
Given n strings consisting only of lowercase English letters, group all strings that are anagrams of one another.
Two strings are anagrams if they contain exactly the same characters with the same frequencies. For example, "eat", "tea", and "ate" belong to the same group.
Output all groups. The order of groups and the order of strings within each group do not matter.
Input Format
The first line contains an integer n, the number of strings.
The next n lines each contain one string.
Output Format
Output one line per anagram group, with strings in the group separated by spaces.
Example
Input:
6
eat
tea
tan
ate
nat
bat
One valid output:
eat tea ate
tan nat
bat
Constraints
1 <= n <= 10^4
Each string has length from 0 to 100.
All strings contain only lowercase English letters.
Example
Input
6
eat
tea
tan
ate
nat
bat
Output
eat tea ate
tan nat
bat