currerentSum = cumulativeSum[j] - cumulativeSum[i-1]
but for i = 0 and whatever be the value of j; we are doing :
currentSum = cumulativeSum[j] - cumulativeSum[-1]; and cumulativeSum[-1] is a garbage value so this might affect the actual result and we might not get the correct maxSum and the subarray.