Money Change Dynamic Programming

I used the bottom up approach and it’s showing Memory Limit Exceeding in the second test case and last test case. What is the correct code?