Find the size of largest subset of anagram words | Utility function to find size of largest subset of anagram ; sort the string ; Increment the count of string ; Compute the maximum size of string ; Driver code
def largestAnagramSet ( arr , n ) : NEW_LINE INDENT maxSize = 0 NEW_LINE count = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT arr [ i ] = ' ' . join ( sorted ( arr [ i ] ) ) NEW_LINE if arr [ i ] in count : NEW_LINE INDENT count [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT count [ arr [ i ] ] = 1 NEW_LINE DEDENT maxSize = max ( maxSize , count [ arr [ i ] ] ) NEW_LINE DEDENT return maxSize NEW_LINE DEDENT arr = [ " ant " , " magenta " , " magnate " , " tan " , " gnamate " ] NEW_LINE n = len ( arr ) NEW_LINE print ( largestAnagramSet ( arr , n ) ) NEW_LINE arr1 = [ " cars " , " bikes " , " arcs " , " steer " ] NEW_LINE n = len ( arr1 ) NEW_LINE print ( largestAnagramSet ( arr1 , n ) ) NEW_LINE