Skip to content

Commit 0be2501

Browse files
committed
Resolved error
1 parent aaa3fcb commit 0be2501

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/java/com/thealgorithms/dynamicprogramming/SubsetSumSpaceOptimized.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
given array sums up to a specific target value.
55
*/
66
public final class SubsetSumSpaceOptimized {
7-
/*
8-
Space Optimized solution using 1D boolean array
9-
Time Complexity: O(n * sum)
10-
Space complexity: O(sum)
11-
*/
7+
private SubsetSumSpaceOptimized(){
8+
}
9+
/**
10+
* This method checks whether the subset of an array
11+
* contains a given sum or not. This is an space
12+
* optimized solution using 1D boolean array
13+
* Time Complexity: O(n * sum), Space complexity: O(sum)
14+
*
15+
* @param arr An array containing integers
16+
* @param sum The target sum of the subset
17+
* @return True or False
18+
*/
1219
public static boolean isSubsetSum(int[] arr, int sum) {
1320
int n = arr.length;
1421
// Declare the boolean array with size sum + 1

0 commit comments

Comments
 (0)