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