Please help me find the possible error.Only 2 test cases are passing.
I have applied matrix chain multiplication kind of DP approach. Please help me identify the error!
Mixtures problem
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.
@abhir26,
You are not filling up the dp table correctly, in matrix chain multiplication, you have to make sure that all dp[I][k] where k belong to [I,j-1] and all dp[k+1][j] where k belongs to[I][j-1] are filled before filling dp[I][j].
The better way to do it is like this.
Also when you have to lets say find min in dp, it’s best to initialise whole dp table with +infinity.