← 返回 meta 的题目列表Anagram / String Transformation (unclear exact prompt)
类型:online_judge
Given an array of strings strs, group the anagrams together and return the groups.
Two strings are anagrams if they contain the same characters with the same frequencies (order may differ). All strings contain only lowercase English letters.
Input:
Line 1: integer n, the number of strings.
Next n lines: one string per line.
Output:
Print multiple lines, each line is one group; strings in a group are separated by spaces. The order of groups and the order within a group do not matter.
Constraints:
1 <= n <= 1e4
1 <= length of each string <= 100
Example:
Input:
6
eat
tea
tan
ate
nat
bat
Output (one valid):
eat tea ate
tan nat
bat
Example
Input
6
eat
tea
tan
ate
nat
bat
Output
(order may vary)
eat tea ate
tan nat
bat