Doubt regarding solution!

In the function written for the longest subbarray I do not think there should be an else loop present while storing the values. In the previous question(length of longest subarray with sum =0) we had two points in the cumulative sum array with the same value therefore we needed an else loop to store the first index while such is not the case here.

I have attached an image of my function below:

Could you please tell me am I right or wrong??

hi @ukd_1574
ur code seems fine…

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.