Algorithm · Apple · Hard
Given an array p of positive integers that represents the dimensions of a chain of matrices, where matrix Ai has size $$p[i-1] \times p[i]$$ for 1 <= i <= n, the full product is A1 * A2 * ... * An. Matrix multiplication is associative, so the chain can be parenthesized in many valid ways. Multiplying an $$x \times y$$ matrix by a $$y \times z$$ matrix requires $$x \cdot y \cdot z$$ scalar multiplications and produces an $$x \times z$$ matrix. Different parenthesizations may…
Checking your access…