Exchanging coins from DP

Here’s my code for exchanging coins. I followed a bottoms-up approach but I am getting a compilation error and I don’t understand what kind of error it is.

hello @div_yanshu07 i have corrected your code and commented the mistake.
https://ide.codingblocks.com/s/358946 .
but your code is not producing the correct result .


Now I have made required changes and I am getting correct output for sample case but I am getting tle when I try to submit it on hackerblocks.

@div_yanshu07 this is because test cases are large .
try to think in some optimised way .
if you still not able to submit you can ask here .

Hey! I tried optimizing it but still not getting result. Please help

hello @div_yanshu07 try this code :


if you don’t understand any line you can ask here.
Happy Learning !!

This is top down approach. I was taking bottoms up approach. Please it would be great of you, if you tell me where I went wrong with my approach.

i think this is the optimised approach .
it is just for practice but it is not correct that every top down can be optimised .