Https://ide.codingblocks.com/#/s/17371

https://ide.codingblocks.com/#/s/17371
my question link: https://hack.codingblocks.com/contests/c/452/266
my 1 test case not passed it shows time limit exceed…

As the time complexity of ur code is O(N2) u must be getting Tle .
Use PigeonHole Principle . As you are asked to find the number of such arrays whose sum is divisible by n, so if you maintain a cummulative sum array then you will see that the sum of the subarray is equal to cs[b]-cs[a-1].
I have made the code for this question . You can see this for help
https://ide.codingblocks.com/#/s/17396
:wink: