Size of the resultant array
let size = parseInt ( Math . sqrt ( n ) , 10 ) ; let brr = new Array ( size ) ; brr . fill ( 0 ) ; let x , l = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( freq [ arr [ i ] ] > 0 && l < size ) {