Pishty and Triangles

Can anyone tell me why this solution of mine gives tle and other is ac although they have same complexity.
The only difference between then is one of them is implements seg tree in recursive fashion and other in iterative fashion?
Question link Pishty and Triangles

1 Like

As you know recursive calls are more costly than iterative methods, thats the reason why you get a TLE. Your iterative method takes 5.58secs in the last test and so its fair that the recursive method easily takes more than 6secs which causes the TLE.

1 Like