Why including null subarray in presum

why are we including null subarray while calculating pre sum

I think your doubt is why we initialized pre[0] = 1.
It is done because for every pre[i] where i=0, we have two types of choices either to take this subarray starting 0 to that index or take it with another array whose sum is also same as it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.