Skip to content

Commit 3b40b3c

Browse files
committed
Fix
1 parent 4d7ceaf commit 3b40b3c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/com/thealgorithms/dynamicprogramming/MatrixChainRecursiveTopDownMemoisation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ static int lookupChain(int[][] m, int[] p, int i, int j) {
5757
return m[i][j];
5858
} else {
5959
for (int k = i; k < j; k++) {
60-
int q = lookupChain(m, p, i, k) + lookupChain(m, p, k + 1, j)
61-
+ (p[i - 1] * p[k] * p[j]);
60+
int q = lookupChain(m, p, i, k) + lookupChain(m, p, k + 1, j) + (p[i - 1] * p[k] * p[j]);
6261
if (q < m[i][j]) {
6362
m[i][j] = q;
6463
}

0 commit comments

Comments
 (0)