Store the count of each element as key value pair in unordered map
for ( var i = 0 ; i < n ; i ++ ) { if ( umap . has ( arr [ i ] ) ) { umap . set ( arr [ i ] , umap . get ( arr [ i ] ) + 1 ) ; } else { umap . set ( arr [ i ] , 1 ) ; } } var maxFreq = 0 ;