Hi, I was just working on this problem, and I noticed that when I changed my operations from division to addition, it resulted in a huge time difference. With division, my code TLEs, while with addition, my code runs in 400ms (you can see where I changed the code on lines 136 and 142). Division is a more costly operation than addition, but why is it causing such a big difference in runtime? Should we avoid more costly operations to prevent TLE?
This Wikipedia article should answer the question and it also has some valuable information in a very compact form ! https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations