In the " currentSum = cumSum[j] + cumSum[i-1]" at itearation i = 0.
Accessing Negative Index
@ritik_gajjar hey ritik yeah you’re right in this case array will try to access a negative index which may contain a garbage value there is a problem in this code you can refer to this line of code maximum subarray sum .
Thanks a lot Neeraj jaiswal.