How to prevent TLE

I am getting TLE in my answer. what can I do to prevent it

Hello @gargayush34,

You have to use an optimized approach to calculate power.
You can refer to the following code:

It is based on an onservation:
if power is even:
a^n=a^(n/2+n/2)=a^(n/2)*a^(n/2)
for odd power:
a^n=a^(n/2+n/2+1)=a^(n/2)*a^(n/2)*a
[because n/2 would take the floor value]

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

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.