Skip to content

Commit a9d7b51

Browse files
committed
Formatted Knapsack.java to pass linter and added 0/1 Knapsack algorithm
1 parent 5bd7036 commit a9d7b51

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
*/
2424
public final class Knapsack {
2525

26-
private Knapsack() {}
26+
private Knapsack() {
27+
}
28+
2729
/**
2830
* Validates the input to ensure correct constraints.
2931
*/
@@ -62,15 +64,15 @@ public static int knapSack(final int weightCapacity, final int[] weights, final
6264
return dp[weightCapacity];
6365
}
6466

65-
/**
66-
* Example main method for demonstration.
67-
67+
/*
68+
// Example main method for local testing only.
6869
public static void main(String[] args) {
6970
int[] values = {60, 100, 120};
7071
int[] weights = {10, 20, 30};
7172
int weightCapacity = 50;
7273
7374
int maxValue = knapSack(weightCapacity, weights, values);
74-
System.out.println("Maximum value = " + maxValue); // Output : 220
75-
} */
75+
System.out.println("Maximum value = " + maxValue); // Output: 220
76+
}
77+
*/
7678
}

0 commit comments

Comments
 (0)