Update the frequencies of all the array elements
for ( let i = 0 ; i < n ; i ++ ) { umap [ arr [ i ] ] ++ ; if ( umap . has ( arr [ i ] ) ) { umap . set ( arr [ i ] , umap . get ( arr [ i ] ) + 1 ) } else { umap . set ( arr [ i ] , 1 ) } } for ( let itr of umap )