Stores frequency of array element
let m = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( m . has ( arr [ i ] ) ) { m . set ( m . get ( arr [ i ] ) , m . get ( arr [ i ] ) + 1 ) } else { m . set ( arr [ i ] , 1 ) ; } }