mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 03:59:38 +08:00
@ -6,7 +6,9 @@ package DynamicProgramming;
|
|||||||
|
|
||||||
public class Knapsack {
|
public class Knapsack {
|
||||||
|
|
||||||
private static int knapSack(int W, int wt[], int val[], int n) {
|
private static int knapSack(int W, int wt[], int val[], int n) throws IllegalArgumentException {
|
||||||
|
if(wt == null || val == null)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
int i, w;
|
int i, w;
|
||||||
int rv[][] = new int[n + 1][W + 1]; //rv means return value
|
int rv[][] = new int[n + 1][W + 1]; //rv means return value
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user