Used to store cumulative sum
int [ ] left = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { left [ i ] = 0 ; } int [ ] right = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { right [ i ] = 0 ; } int [ ] res = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { res [ i ] = 0 ; }