DIVISIBLE SUBARRAYS why do i get wrong answer in in test case 1
Hello @khushipriya681,
-
To convert the negative numbers to positive, you have to first limit them in a range from 0 to n-1
Reason:
sum=(sum+n)%n; would not work for the case when the sum < -n -
The case when prefix[i]*(prefix[i]-1) is a large value (say long)
prefix is of type int.
So,
product of int and int will result into int.
I have modified your code:
Hope, this would help.
Give a like, if you are satisfied.
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.