I didn’t get why he did sum%=n and again sum = (sum+n)%n and what all Prateek Bhaiya said about modulus of negative numbers
Negative modulus
And also that we should be storing the sum separately right? Why didn’t we need that?
@ankurguria when we have to take the modulus of negative number we add the number from which we are taking modulo and then take modulo.
in this problem we dont need to store sum we just count which sum occurs how many times,since we are takin modulo with n all sums will be less than n.
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.