Whats wrong with my code

Use long datatype.
And you’ll need to use memoization or DP to avoid getting TLE.

hey should i leave all recursion assignment and learn dp and then come back to solve recursion problems??

my answer in recursion is correct or not ??

Your recursive relation is correct. But you have to do this question with DP to pass all the test cases.
So i would suggest you to learn dp first.

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.