Initialize prefix arrays to store number of changes required to put 1 s at either even or odd position
let oddone = Array . from ( { length : n + 1 } , ( _ , i ) => 0 ) ; let evenone = Array . from ( { length : n + 1 } , ( _ , i ) => 0 ) ; oddone [ 0 ] = 0 ; evenone [ 0 ] = 0 ; for ( let i = 0 ; i < n ; i ++ ) {