Exchanging coins

my code is running fine but here it is showing run error

hello @vanisinghal0201

a) value of n can be upto 10^9 ,u have declared a small size dp array, which will not work.
also we cannot declare dp array of size 10^9 because this will consume too much memory.
so use map and top down dp.

b) dont check whether i is divisible by 2,3,4. if it is not then take their floor value.

check this code->

2 Likes

why we are not checking divisibility

In actual question it is mentioned to take floor value .

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.

1 Like