Reversing the array to use the same existing function for operations of the second type
let reverse_arr = new Array ( size ) ; for ( let i = 0 ; i < size ; i ++ ) reverse_arr [ size - 1 - i ] = arr [ i ] ; resSum = Math . max ( resSum , maxSumSubWithOp ( reverse_arr ) ) ; return resSum ; }