Driver code
let array = [ - 12 , - 11 , - 13 , - 5 , - 6 , 7 , 5 , 3 , 6 ] ; let length = array . length ; let countNegative = 0 ; for ( let i = 0 ; i < length ; i ++ ) { if ( array [ i ] < 0 ) countNegative ++ ; } document . write ( " " ) ; printArray ( array , length ) ; rearrange ( array , 0 , ( length - 1 ) ) ; reverse ( array , countNegative , ( length - 1 ) ) ; document . write ( " " ) ; printArray ( array , length ) ;