Function to return the vector representing the right to left Kadane array as described in the approach
function getRightToLeftKadane ( arr ) { let max_so_far = 0 , max_ending_here = 0 ; let size = arr . length ; let new_arr = new Array ( size ) ; for ( let i = 0 ; i < size ; i ++ ) new_arr [ i ] = arr [ i ] ; for ( let i = size - 1 ; i >= 0 ; i -- ) { max_ending_here = max_ending_here + new_arr [ i ] ; if ( max_ending_here < 0 ) max_ending_here = 0 ; else if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; new_arr [ i ] = max_so_far ; } return new_arr ; }