Traverse the array
for ( let i = 0 ; i < N ; i ++ ) { if ( m . has ( arr [ i ] ) ) { m . set ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) } else { m . set ( arr [ i ] , 1 ) } } for ( let i = 0 ; i < N ; i ++ ) {