Exchanging Coins

Please help, it is giving Run error

hello @Karanveer in this question as the test cases are very large thats why we need to handle the cases separately .
here is the correct code.


i have just implemented your code in different cases.
tell me if you dont understand any thing .
i hope i have cleared your doubt .
Happy Learning !!

I couldn’t understand the code, please explain in detail…

I couldn’t understand the code, please explain in detail…

@Karanveer everything is same as your code but just 2-3 conditions like when when n is less than 10 then we should return n only this you can try yourself also because when n is less than 10 the number itself is the greatert instead of breaking thats why we have done it in that way.
then we have further divided the condition that if n<1e6 here we are storing the answer in our dp array.
there is no big theory in this it is just the trick to do and handle large test cases .
i hope i have cleared your doubt .
Happy Learning!!

Thanks, understood it now… also, what is int32_t ??

@Karanveer if you see above i have declared int as long long int
so for that if i will not declare main like this .
it will throw an error .
so for that we are doing this .

Thanks for helping :relaxed: