Increase the frequency of elements
for ( let i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) != null ) { let x = mp . get ( a [ i ] ) ; mp . set ( a [ i ] , ++ x ) ; } else mp . set ( a [ i ] , 1 ) ; } let count = 0 ;