Map to store the frequency of each element
mp = dict ( ) NEW_LINE ans = 1 NEW_LINE cnt = n NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( ar [ i ] in mp ) : NEW_LINE INDENT mp [ ar [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ ar [ i ] ] = 1 NEW_LINE DEDENT DEDENT