Skip to content

Commit 854a13d

Browse files
committed
subset sum problem dynamic programming
1 parent 9aba929 commit 854a13d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/dymanicProgramming/SubsetSumProblem.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*/
66
public class SubsetSumProblem {
77

8-
private static boolean[][] sol;
9-
10-
private static Boolean isSubsetSum(int[] set, int sum) {
8+
private static boolean isSubsetSum(int[] set, int sum) {
9+
boolean[][] sol = new boolean[set.length][sum + 1];
1110
for (int x = 0; x < set.length; x++) {
1211
for (int k = 0; k <= sum; k++) {
1312
if (set[x] == k) {
@@ -26,7 +25,6 @@ private static Boolean isSubsetSum(int[] set, int sum) {
2625
public static void main(String[] strings) {
2726
int set[] = {3, 34, 4, 12, 5, 2};
2827
int sum = 29;
29-
sol = new boolean[set.length][sum + 1];
3028
if (isSubsetSum(set, sum))
3129
System.out.println("Found a subset with given sum");
3230
else

0 commit comments

Comments
 (0)