Construct hash for positive elements
for ( int i = 0 ; i <= n - 1 ; i ++ ) { if ( arr [ i ] > 0 ) { if ( hashPositive . ContainsKey ( arr [ i ] ) ) { hashPositive [ arr [ i ] ] += 1 ; } else { hashPositive . Add ( arr [ i ] , 1 ) ; } } }