Matrix Chain Multiplication Recursive
Medium

Problem Statement

Given a sequence of matrix dimensions, determine the minimum number of scalar multiplications needed to multiply the entire chain using simple recursion.

Examples

1Example 1
Input:
{ "dims": [ 40, 20, 30, 10, 30 ], "i": 1, "j": 4 }
Output:
26000
2Example 2
Input:
{ "dims": [ 10, 30, 5, 60 ], "i": 1, "j": 3 }
Output:
4500
3Example 3
Input:
{ "dims": [ 10, 20, 30, 40, 30 ], "i": 1, "j": 4 }
Output:
30000
Loading...

Sign in to Run Code and Submit