Find whether each element is positive or negative
for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) sign [ i ] = 1 ; else sign [ i ] = - 1 ; } let k = 0 ; let result = Array . from ( { length : n } , ( _ , i ) => 0 ) ;