Construct hash for positive elements
for ( let i = 0 ; i <= n - 1 ; i ++ ) { if ( arr [ i ] > 0 ) { if ( hashPositive . has ( arr [ i ] ) ) { hashPositive . set ( arr [ i ] , hashPositive . get ( arr [ i ] ) + 1 ) ; } else { hashPositive . set ( arr [ i ] , 1 ) ; } } }