Skip to content

Commit 107c23a

Browse files
committed
Fix:#5502
1 parent 7f60d57 commit 107c23a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.thealgorithms.dynamicprogramming;
2+
3+
public class ArrayList<T> {
4+
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.thealgorithms.dynamicprogramming;
2+
import java.util.ArrayList;
3+
public class subsetRecursion {
4+
public static void subset(String prefix, String str, ArrayList<String> result) {
5+
// Base case: if the string is empty, add the prefix to the result
6+
if (str.isEmpty()) {
7+
result.add(prefix);
8+
return;
9+
}
10+
// Recursive call by including the first character in the prefix
11+
subset(prefix + str.charAt(0), str.substring(1), result);
12+
13+
// Recursive call by excluding the first character
14+
subset(prefix, str.substring(1), result);
15+
16+
}
17+
}

0 commit comments

Comments
 (0)