Increasing the frequency of every element
for ( int i = 0 ; i < n ; i ++ ) { int c = a [ i ] ; if ( freq . containsKey ( c ) ) { freq . put ( c , freq . get ( c ) + 1 ) ; } else { freq . put ( c , 1 ) ; } }