#K60812. Largest Anagram Group
Largest Anagram Group
Largest Anagram Group
You are given a list of words. Your task is to identify the largest group of anagrams from the given list. Two words are anagrams if they consist of the same characters in a different order. In other words, for a word \(w\), its sorted key is obtained by sorting the characters of \(w\) in ascending order. Words sharing the same sorted key are anagrams.
If more than one group of anagrams has the maximum size, choose the group whose sorted key is lexicographically smallest. The output should list the words in the order they appear in the input.
Note: When two groups are tied for size, the comparison is made using the sorted key in \(\LaTeX\) form: \(\textrm{key} = sorted(word)\).
inputFormat
The first line contains an integer \(n\), the number of words. The second line contains \(n\) words separated by a single space.
outputFormat
Output a single line containing the largest group of anagrams. The words should be printed in the same order as they appear in the input and separated by a single space.
## sample7
listen silent enlist google gooegl inlets banana
listen silent enlist inlets