Refactor Code Style (#4151)

This commit is contained in:
Saurabh Rahate
2023-04-15 13:55:54 +05:30
committed by GitHub
parent 1ce907625b
commit 1dc388653a
100 changed files with 293 additions and 319 deletions

View File

@ -5,13 +5,13 @@ package com.thealgorithms.dynamicprogramming;
*/
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 rv[][] = new int[n + 1][W + 1]; // rv means return value
int[][] rv = new int[n + 1][W + 1]; // rv means return value
// Build table rv[][] in bottom up manner
for (i = 0; i <= n; i++) {
@ -34,9 +34,9 @@ public class Knapsack {
}
// Driver program to test above function
public static void main(String args[]) {
int val[] = new int[] { 50, 100, 130 };
int wt[] = new int[] { 10, 20, 40 };
public static void main(String[] args) {
int[] val = new int[] { 50, 100, 130 };
int[] wt = new int[] { 10, 20, 40 };
int W = 50;
System.out.println(knapSack(W, wt, val, val.length));
}