Create an dictionary and store frequencies of all array elements in it using element as key and frequency as value
freq = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] in freq : NEW_LINE INDENT freq [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT freq [ arr [ i ] ] = 1 ; NEW_LINE DEDENT DEDENT