Facing Timeout in one of the test case

https://ide.codingblocks.com/s/51540
Question is Divisible SubArrays in Hackerblocks
How to optimise this code???

Hi, please share the link of the question.

Hey Vishesh, your code’s time complexity is O(N^2) that’s why its not working. I have optimized your code you can refer this.

thanks but i m not getting the logic behind it.Can u explain it a bit please!!