Key in map will store elements and value will store the frequency of the elements
let mp = new Map ( ) ; for ( let i = 0 ; i < N ; ++ i ) if ( mp . has ( arr [ i ] ) ) { mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) } else { mp . set ( arr [ i ] , 1 ) } let answer = 0 ; for ( let i of mp ) {