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