Even and odd divisors

Getting TLE :- https://ide.codingblocks.com/s/222252

Hello @aiman.mumtaz,

It is giving TLE (Time Limit Exceeded) because you have run 2 loops which is 10^6 * 10^6 =10^12 operations.
But the maximum number of operations allowed in 1 sec which is nearly 10^8 operation.

Thus, try to reduce it to O(N) and less i.e. linear time complexity.
Hint:

Suggestion:
Try to think of storing the sum of even and odd divisors and then print the result as even sum - odd sum.

Hope, this would help.
Give a like if you are satisfied.

1 Like