File tree 1 file changed +5
-5
lines changed
src/main/java/com/thealgorithms/dynamicprogramming 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,17 @@ private SubsetSum() {
9
9
*
10
10
* @param arr the array containing integers.
11
11
* @param sum the target sum of the subset.
12
- * @return {@code true} if a subset exists that sums to the given value, otherwise {@code false}.
12
+ * @return {@code true} if a subset exists that sums to the given value,
13
+ * otherwise {@code false}.
13
14
*/
14
15
public static boolean subsetSum (int [] arr , int sum ) {
15
16
int n = arr .length ;
16
17
17
- //Intialize Two Arrays to store current and prev states
18
+ // Intialize Two Arrays to store current and prev states
18
19
boolean [] isSumCurr = new boolean [sum + 1 ];
19
- boolean [] isSumPrev = new boolean [sum + 1 ];
20
+ boolean [] isSumPrev = new boolean [sum + 1 ];
20
21
21
- // Mark prev[0] = true as it is true to make sum = 0
22
- // using 0 elements
22
+ // Mark prev[0] = true as it is true to make sum = 0 using 0 elements
23
23
isSumPrev [0 ] = true ;
24
24
25
25
// Fill the subset sum matrix
You can’t perform that action at this time.
0 commit comments