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

Sign up
Appearance settings

Commit 1a421f8

Browse files
Changes
1 parent ac8dfa9 commit 1a421f8

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

‎Java/Algorithm/DynamicProgramming/ClimbStairs/ClimbStairs1.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void main(String[] args) {
2626
int n = sc.nextInt();
2727
int ans = solution(n);
2828
System.out.println(ans);
29-
// sc.close();
29+
sc.close();
3030

3131
}
3232

‎Java/Algorithm/DynamicProgramming/ClimbStairs/ClimbStairs2.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//we given an array jumps where jump[i] represents from ith step we can go to i+jumps[i] ith steps;
44
//we have to start from 0th step and reach the nth step using jumps
55

6-
import java.util.Scanner;
7-
86
public class ClimbStairs2 {
97
public static int getNoOfWays(int n, int[] jumps) {
108
int[] dp = new int[n + 1];
@@ -20,7 +18,6 @@ public static int getNoOfWays(int n, int[] jumps) {
2018
}
2119

2220
public static void main(String[] args) {
23-
Scanner sc = new Scanner(System.in);
2421
int n = 6; // number of steps;
2522
int[] jumps = { 2, 3, 0, 1, 2, 3 };
2623
int ans = getNoOfWays(n, jumps);

‎Java/Algorithm/DynamicProgramming/ClimbStairs/ClimbStairs3.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public static int getNoOfWays(int n, int[] jumps) {
2121
}
2222

2323
public static void main(String[] args) {
24-
Scanner sc = new Scanner(System.in);
2524
int n = 6; // number of steps;
2625
int[] jumps = { 2, 3, 0, 1, 2, 3 };
2726
int ans = getNoOfWays(n, jumps);

‎Java/Algorithm/DynamicProgramming/KnapSack/BoundedKnapSack.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
public class BoundedKnapSack {
2-
public static int Solve(int W, int N, int[] val, int[] wt) {
2+
public static int solve(int W, int N, int[] val, int[] wt) {
33
int[][] dp = new int[N + 1][W + 1];
44
// dp[i][j] represents max value achieved with sack of capacity j and i-1 items;
55
for (int i = 1; i <= N; i++) {
@@ -23,7 +23,7 @@ public static void main(String[] args) {
2323
int[] val = { 1, 2, 3 }; // values of items;
2424
int[] wt = { 3, 5, 1 }; // weights of items
2525

26-
int ans = Solve(W, N, val, wt);
26+
int ans = solve(W, N, val, wt);
2727
System.out.println(ans);
2828
}
2929
}

‎Java/Algorithm/DynamicProgramming/KnapSack/UnboundedKS.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//this problem is quite similar to coinChange2
33

44
public class UnboundedKS {
5-
public static int Solve(int W, int N, int[] val, int[] wt) {
5+
public static int solve(int W, int N, int[] val, int[] wt) {
66
int[] dp = new int[W + 1];
77
// dp[i] represents max Value achieved with sack of capacity of i
88
for (int i = 0; i <= W; i++) {
@@ -22,7 +22,7 @@ public static void main(String[] args) {
2222
int N = 3; // No of items
2323
int[] val = { 1, 2, 3 }; // values of items;
2424
int[] wt = { 3, 5, 1 }; // weights of items
25-
int ans = Solve(W, N, val, wt);
25+
int ans = solve(W, N, val, wt);
2626
System.out.println(ans);
2727
}
2828
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /