Minimum coin change problem

In the Bottom up approach , code is giving wrong answer for the test case in which there is 3 denomination = [5,7,9] and the coin value is 7.

i am getting an output (-2147483648 ) , i think problem is with the initialization of the dp array with INT_MAX.

plz help?

hello @Shivam_singh

please share the code(that u r referring) using cb ide

@aman212yadav
ide - https://ide.codingblocks.com/s/338956

image

add this extra condition

@aman212yadav how can i deal with those value which cannot be made from any combination of the denomination like in the ex:
3
5 7 9
6
6 cannot be made from any combination, so the code should return the 0 instead of returning INT_MAX?

in the last before return statement check whether dp[price] is INT_MAX or not.
if it is then return 0
otherwise return dp[price]

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.