Mixtures problem

why it is giving wrong output in testcase 0,1,2.

@rohit2299
for bigger test cases(even in range of 10), your soln is not giving the most optimal solution
you can simply make the mixtures funtion (similar to MCM) as follows:
iand j are start and end pts of array
long long Mixtures(int i,int j){
if(i>=j){
return 0;
}
// checking for if the soln is already present(overlapping subproblem)
if(dp[i][j]!=-1){
return dp[i][j];
}
//trying to break the eq at every possible k
dp[i][j] = INT_MAX;
for(int k=i;k<=j;k++){
dp[i][j] = min(dp[i][j], solveMixtures(i,k)+solveMixtures(k+1,j)+csum(i,k)*csum(k+1,j));
}
return dp[i][j];
}

I have applied same approach (MCM), but then also it is giving wrong output.

can u please go through my code.

@rohit2299
refer to this corrected code


mark your doubt as resolved if u are satisfied :slight_smile: