I did’nt understand why sanket bhaiya add 2 in prefix sum sub array to find the sum of sub array.
Why they add 2 in prfix sum array?
Mention the timestamp in the video so that i can check.
check at 3 : 27 ,prefix sum array
For sum of subarray starting from index 1 till 4, you can simply do prefixsum[4]-prefixsum[0]=15-1=14
This is also equal to prefixsum[4]-prefixsum[1]+array[1]=15-3+2=14
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.