Counting freq of each element
if ( mpp . has ( arr [ i ] ) ) { mpp . set ( arr [ i ] , mpp . get ( arr [ i ] ) + 1 ) } else { mpp . set ( arr [ i ] , 1 ) } } let ans = 0 ; for ( let x of mpp ) { let value = x [ 0 ] ; let freq = x [ 1 ] ;