Stores difference with element on the right
let rightDP = new Array ( Math . floor ( n / 2 ) ) ; for ( let i = 0 ; i < n / 2 ; i ++ ) { leftDP [ i ] = 0 ; rightDP [ i ] = 0 ; } let c = 0 ; for ( let i = 1 ; i < n ; i = i + 2 ) {