Please explain this condition i.e. if(pre==0) length=max(length,i+1;

Please explain this condition i.e. if(pre==0) length=max(length,i+1;

@cbcao263
Suppose the array is
2,-2,3
you encounter 2 , sum is 2; // i = 0;
you encounter -2, now sum is 0. // i = 1
In this case, this condition would trigger.
and length=max(length,i+1);

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.