Is the logic wrong?

Link to my code: https://ide.codingblocks.com/s/219159

I’m getting a TLE. Can someone give me a hint.

Thanks.

@kapurm17 hi ,apka code sahi hai but apne recursion use ki hai which is giving
TLE so use dp ,you can check out this logic and try it yourself:

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.