Doubt in question

why do we have to do sum+=(sum+N)%N
while we have already written sum=sum%N ???

@himanshu24 its to take care of the negative results, if sum%n is negative then sum will be negative and we dont want that, so doing sum+n ensures the result will be positive and it has no impact on the actual answer because of mod properties

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.