Matrix Chain Multiplication Cost

Given an array dims of length m, matrix i (1-indexed in order) has dimensions dims[i - 1] x dims[i] for 1 <= i < m. The matrices must be multiplied in this fixed order, but you may choose any parenthesization. Multiplying a p x q matrix by a q x r matrix costs p * q * r scalar multiplications and produces a p x r matrix.

Return the minimum number of scalar multiplications needed to compute the full matrix chain product.

Examples
Input: [10,30,5,60]
Output: 4500
Hints

Matrix Chain Multiplication Cost

Given an array `dims` of length `m`, matrix `i` (1-indexed in order) has dimensions `dims[i - 1] x dims[i]` for `1 <= i < m`. The matrices must be multiplied in this fixed order, but you may choose any parenthesization. Multiplying a `p x q` matrix by a `q x r` matrix costs `p * q * r` scalar multiplications and produces a `p x r` matrix.