Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9743e75

Browse filesBrowse files
authored
Update Knapsack.java
Added check if the arrays are null
1 parent 23ca716 commit 9743e75
Copy full SHA for 9743e75

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Collapse file

‎DynamicProgramming/Knapsack.java‎

Copy file name to clipboardExpand all lines: DynamicProgramming/Knapsack.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
public class Knapsack {
88

9-
private static int knapSack(int W, int wt[], int val[], int n) {
9+
private static int knapSack(int W, int wt[], int val[], int n) throws IllegalArgumentException {
10+
if(wt == null || val == null)
11+
throw new IllegalArgumentException();
1012
int i, w;
1113
int rv[][] = new int[n + 1][W + 1]; //rv means return value
1214

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.