Skip to content

Commit 348c0ff

Browse files
committed
Formatted KnapsackMemoization.java and optimized algorithm
1 parent f8e182a commit 348c0ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ int knapSack(int capacity, int[] weights, int[] profits, int numOfItems) {
1818
int[][] dpTable = new int[numOfItems + 1][capacity + 1];
1919

2020
// Loop to initially fill the table with -1
21-
for(int []table:dpTable){
22-
Arrays.fill(table,-1);
21+
for (int[] table : dpTable) {
22+
Arrays.fill(table, -1);
2323
}
2424

2525
return solveKnapsackRecursive(capacity, weights, profits, numOfItems, dpTable);

0 commit comments

Comments
 (0)