for (int i = 0; i < size; ++i)
{
for (int j = i; j < size; ++j)
{
int currentSum = cumulativeSum[j] - cumulativeSum[i-1];
if (currentSum > maximumSum)
{
maximumSum = currentSum;
startIndex = i;
endIndex = j;
}
}
}
here cumulativeSum[i-1] for i = 0 gives wrong answer. Please helf how to resolve this