Anagrams Revisited

3.5

111 votes
Map, Sorting, Easy, Hash table, Data Structures
Problem

Arnab is a robber and he has managed to rob N different strings from Akash. Now he decides to sell these strings in the market to make some profit. But, of all the strings he has, he wants to find the size of the largest anagram group so that he can easily sell that one first and make maximum profit initially. Help him find the largest size of groups of anagrams.

An anagram of a string is another string that contains same characters, only the order of characters can be different. For example, “abcd” and “dabc” are anagram of each other.

Input:
First line of input contains an integer N, number of total strings. Next N lines contains a single string S.

Output:
Print the largest size of group of anagrams possible.

Constraints:
1N100000
1|S|50

Sample Input
5
ab
ba
cab
bca
cba
Sample Output
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Groups of anagrams that can be formed are :
{ab,ba}
{cab, bca, cba}
So the answer is 3 as largest size of group of anagram is 3.

Editor Image

?