Exchanging coins

I’m getting run time error on submit but I’m getting the correct answer for sample test case. Please check for correction.

Check the constraints
Constraints

0 <= n <= 1 000 000 000

Generally an array of size 10^9 cannot be made. But here n can range upto 10^9. So idea is to use hashmap for memo table and follow top down approach. Go through this discussion Exchanging coins

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.