Pls check the code its giving mle

problem is with large constraint of the problem
Constraints

0 <= n <= 1 000 000 000

you can’t make such a huge dp array in c++

so you have to use the top down dp here

you can see the Reference code

for n<=1000000 use dp array

and for n>1000000 use recursion
Reference code

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.