Divisible subarrays

SOME THING went to wrong in my program 1 testcase correct and 2 testcase have run error
this is link my code


tell where i wrong

Hello @khemchandrs,

There are three mistakes in your code that can lead to error for the larger value of n.

  1. The prefix_sum[i] and the final sum can have values greater than the range of int.
    (wrong output)

  2. The sum can also be negative:
    (run-error)
    Solution:
    prefix_sum[i]=(prefix_sum[i]+n)%n;

  3. for the value of n=10^4, frequency[] array can have the 9999 also.
    And it is difficult to compute the factorial of this big number.
    Suggestion:
    Google, 9999!=
    Solution:
    Use the simplified equation to compute the combination as specified in the video.

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.