Given the dimensions of n
matrices M1..Mn
, what is the minimum number of multiplication in M1 x M2 x ... x Mn
.
Suppose dimensions are given as [10, 30, 5, 60]
, meaning 3 matrices with dimensions 10 x 30
, 30 x 5
and 5 x 60
, (AB)C
requires 10x30x5 + 10x5x60 = 4500
operations while A(BC)
requires 30x5x60 + 20x30x60 = 27000
operations. Therefore, the function should return 4500
.