#C11165. Largest Anagram Group Size
Largest Anagram Group Size
Largest Anagram Group Size
You are given a number of test cases. For each test case, you are provided with a list of words. Your task is to determine the size of the largest group of words that are anagrams of each other. Two words are anagrams if one can be rearranged to form the other. Formally, for a given test case with n
words, let \( f(s) \) be the function that sorts the characters of string \( s \) in non-decreasing order. Then words \( s_i \) and \( s_j \) are anagrams if \( f(s_i) = f(s_j) \). Your task is to compute, for each test case, the maximum frequency of any anagram group.
Input Constraints:
- The number of test cases \( T \) satisfies \( 1 \le T \le 10 \).
- The number of words for a test case \( n \) satisfies \( 1 \le n \le 10^5 \) (in aggregate over all test cases, the total number of words will be manageable).
- Each word consists of lowercase English letters only.
Example:
Input: 3 4 listen silent enlist google 3 bat tab cat 5 abc bca cab bac acb</p>Output: 3 2 5
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer \( T \), the number of test cases.
- For each test case:
- The first line contains an integer \( n \), the number of words.
- The next line contains \( n \) space-separated words.
For example:
3 4 listen silent enlist google 3 bat tab cat 5 abc bca cab bac acb
outputFormat
For each test case, output a single line containing one integer — the maximum size of a group of anagrams among the given words. The output is written to stdout.
For example:
3 2 5## sample
3
4
listen silent enlist google
3
bat tab cat
5
abc bca cab bac acb
3
2
5
</p>