func solve(A[], i, j){
if(i>j) <!--May be change as per question requirement-->
return 0;
for(k=i; k<=j; k++){
temp = solve(A, i, k) + solve(A, k+1, j) + (A[i-1] * A[k] * A[j]);
answer = MAX/MIN(temp, answer);
}
return answer;
}
- Find right i and j values
- Find right base condition
- Move k -> i to j
- Find extra cost (A[i-1] * A[k] * A[j])
Variants of MCM Based questions:
- Cost of multiplication of matrices
- Evaluate Expression true
- Palindrome Partitioning
- Scrambled String
- Egg Drop