Find maximum element in array and fill frequency map .
for i in range ( n ) : NEW_LINE INDENT arrMax = max ( arrMax , arr [ i ] ) NEW_LINE if arr [ i ] not in freq : NEW_LINE INDENT freq [ arr [ i ] ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT freq [ arr [ i ] ] += 1 NEW_LINE DEDENT DEDENT