Modified the code still getting runtime error!
link:https://ide.codingblocks.com/s/176361
Coin Change Problem
Hello Auditya,
In line number 28,change m to m+1 and intialise dp[i][j] with -1.
output now is -2, and why to initialize it with -1,
and also size should be m why to make it m+1
@Codemaniac_Aditya
here is your working code link - https://ide.codingblocks.com/s/176996
a) why m+1 and not m?
we are checking dp[n][m] which is only possible when size is m+1
b) why to initialise with -1 and not 0
dp[n][m] =-1 will clearly tell us that we have not seen this state before
1 Like