The complete array is reversed so that the subarray can be processed as arr [ 0. . . i ] instead of arr [ i ... N - 1 ]
arr = arr [ : : - 1 ] NEW_LINE copyArr = arr NEW_LINE for i in range ( 1 , size , 1 ) : NEW_LINE INDENT getUpdatedArray ( arr , copyArr , i ) NEW_LINE resSum = max ( resSum , maxSumSubarray ( copyArr , size ) ) NEW_LINE DEDENT resSum += 6 NEW_LINE return resSum NEW_LINE