store frequency of each element
for ( let i = 0 ; i < n ; i ++ ) { mp [ arr [ i ] ] ++ ; if ( mp . has ( arr [ i ] ) ) { mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) } else { mp . set ( arr [ i ] , 1 ) } }