My code gives time limit

can i get some other way of solving it i watched the hint video
heres my code link

Hey @sshreya2912
If you analyse carefully you just to print the Nth fibonacci number
Try to print that and see if it works
If your doubt is resolved please close it

i made a recursive function kind of like fibonaci but different and it is giving TLE

@sshreya2912
I do realise that
The issue is your codes time complexity is 2^N which will give TLE for N >= 22 approx
If you use normal fibonacci code it works in O(N)
Please use that

like the non recursion one?

@sshreya2912
See method 2 and 3 in this

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.

I am getting right answer for one of the testcases and tle for the rest theres link to the code in the thread

@sshreya2912
I have corrected your code, you just have to store the values of the functions so that you don’t recompute them again.

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.