This is memo to get the max sum in the subarray of the array. If you just want to get the max value, this is the code
n is the number of elements in the array. This code calculates the max value in the array. Then, I wondered what if I want the elements of the sub array? So I added the code to keep index of the subarray beginning and where the sub array ends.
Now the code prints out the elements in the sub array!