metoop / Dynamic-programming

MIT License
2 stars 7 forks source link

Matrix Chain Multiplication #7

Closed pradeexsu closed 4 years ago

pradeexsu commented 4 years ago
We have many options because matrix multiplication is an associative operation, meaning that the order in which we multiply does not matter. The optimal order depends only on the dimensions of the matrices.
The brute-force algorithm is to consider all possible orders and take the minimum. This is a very inefficient method.
Implement the minimum multiplication algorithm using dynamic programming.

Input Format

The input file must contain the dimensions of the matrices each on a separate line.

Constraints

Input should consist of positive integers.

Output Format

The output file must contain the minimum number of multiplications needed to multiply the matrices as an integer.

Sample Input

20  
2  
30  
12  
8

Sample Output

1232

Explanation

The above input and output samples correspond to the multiplication of these four matrices:

*A1 (20x2) A2 (2x30) A3 (30x12) A4 (12x8) note : read readme.md carefully**

pradeexsu commented 4 years ago

your code should pass HackerRank test case

almas33 commented 4 years ago

please assign this issue to me

pradeexsu commented 4 years ago

@almas33 read readme carefully

pradeexsu commented 4 years ago

go ahead