Incrementing the frequency of the element by 1.
if ( ! mp . ContainsKey ( arr [ i ] ) ) mp . Add ( arr [ i ] , 1 ) ; else { int x = mp [ arr [ i ] ] ; mp [ arr [ i ] ] = mp [ arr [ i ] ] + ++ x ; } } for ( int i = 0 ; i < n ; ++ i ) {