Where am i going wrong?
there were couple of small errors
- k should start from j+1 and not j, and you should which means csm would be cs[k] - cs[j]
- output would be maxs
but formula of sum of subarray for i to j is cs[j]-cs[i-1].
j was starting from 0, you were trying to access cs[-1].
but in the video as you can see in the screenshot ‘i’ is starting from 0 and ‘j’ is starting from ‘i’.
and prateek sir is not getting any error. How it is possible?
hey @itismohiton it depends on the ide, some ide return garbage value for out of index requests which is zero in some ide’s so both of those factors combined allows this to happen.
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.
