Storing the number of occurrence of elements in unordered map
for ( int i = 0 ; i < n ; i ++ ) { if ( ! m . containsKey ( v [ i ] ) ) m . put ( v [ i ] , 1 ) ; else m . replace ( v [ i ] , m . get ( v [ i ] ) + 1 ) ; } int count = 0 ;