problem in cumulative sum array
why pre[0]=1
Problem in cumulative sum array
@uditkumar652
The cumulative sum array is used to indicate the occurences of subarrays with sum = i where i is our current index. That is , the pre[0] indicates the number of subarrays whose sum is 0. Now we know for a fact that there would always be a subarray with sum = 0 which would be the NULL subarray i.e. the subarray with no elements in it. Hence we mark its sum’s occurence as 1 before beginning the iterations.