#C14467. Anagram Groups
Anagram Groups
Anagram Groups
You are given a list of n strings. Your task is to group the strings into groups of anagrams. Two strings are anagrams if they contain the same characters in any order. In other words, strings s and t are anagrams if and only if
$$sorted(s)=sorted(t)$$
Each group should preserve the order of appearance from the input. Print each group on a new line with the words separated by a single space. Note that if there are no strings, you should output nothing.
Example: For input "eat tea tan ate nat bat", the anagram groups are:
- Group 1:
eat tea ate
- Group 2:
tan nat
- Group 3:
bat
inputFormat
The first line contains an integer n denoting the number of strings.
The second line contains n strings separated by spaces.
outputFormat
Print the grouped anagrams. Each group must appear on a separate line with the strings in the same order as they appeared in the input, separated by a single space.
## sample6
eat tea tan ate nat bat
eat tea ate
tan nat
bat
</p>