diff --git "a/Beginner Level \360\237\223\201/Matrix Chain Multiplication" "b/Beginner Level \360\237\223\201/Matrix Chain Multiplication" deleted file mode 100644 index 43367605..00000000 --- "a/Beginner Level \360\237\223\201/Matrix Chain Multiplication" +++ /dev/null @@ -1,28 +0,0 @@ -# Matrix Chain Multiplication - -Given an array `p` where `p[i]` represents the dimensions of the matrix \(A_i\) such that \(A_i\) has dimensions \(p[i-1] \times p[i]\) (for \(i \geq 1\)), find the minimum number of scalar multiplications needed to compute the product of a chain of matrices \(A_1 \times A_2 \times \ldots \times A_n\). - -The goal is to determine the most efficient order of multiplying these matrices. Matrix multiplication is associative, meaning the order of multiplication can be changed to reduce the number of scalar multiplications. However, matrices can only be multiplied if the number of columns in one matrix equals the number of rows in the next. - -For example, given the array `p = [10, 20, 30, 40, 30]`, matrices \(A_1\), \(A_2\), \(A_3\), and \(A_4\) would have dimensions \(10 \times 20\), \(20 \times 30\), \(30 \times 40\), and \(40 \times 30\), respectively. The goal is to find the minimum cost to compute \(A_1 \times A_2 \times A_3 \times A_4\). - -## Input -- An integer array `p` of size \( n+1 \), where \( n \) is the number of matrices. - -## Output -- An integer representing the minimum number of scalar multiplications needed to multiply the chain of matrices. - -### Constraints: -- \( 1 \leq n \leq 100 \) -- \( 1 \leq p[i] \leq 500 \) - -## Example - -**Input:** -p = [10, 20, 30, 40, 30] - -**Output:** -30000 - -**Explanation:** -The optimal order of multiplication is \(( (A_1 \times A_2) \times (A_3 \times A_4) )\), with a minimum cost of 30000 scalar multiplications.