output is int_max
why are the values in dp array not being updated?
Garbage value output please check
Check now.
there is no code in the link
Replace line 19 and 20 with
if(mini!=INT_MAX)
dp[i]=mini;
still wrong answer:
Change line 12 to if(i-a[j]>=0){
still incorrect
test cases not passing on hackerblocks.
Please share the link of the question.
Is the question is to find the minimum number of coins to form the target sum?
In the question it is given that you have to find the total number of ways you can make the change for value N.
What exactly you code is doing is finding the minimum number of coins required to make value N.
Considering Sample input :
10 4
2 5 3 6
Your Output:
2… as minm number of coins required to form value 10 is 2 ie. 5+5
Expected Output:
5… (the total number of ways you can form value 10)
Try to think of a logic and code again.
You can refer this for the logic.
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.