-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathSubsets.java
More file actions
28 lines (24 loc) · 672 Bytes
/
Copy pathSubsets.java
File metadata and controls
28 lines (24 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package java.solution;
//import java.util.*;
public class Subsets {
public static void findsubsets(String str, String ans, int i){
//base case
if(i==str.length()){
if(ans.length()==0){
System.out.println("{ }");
}
else{
System.out.println("{"+ans+"}");
}
return;
}
//yes choice
findsubsets(str, ans+str.charAt(i), i+1);
//no choice
findsubsets(str, ans, i+1);
}
public static void main(String[] args) {
String str="abc";
findsubsets(str, "", 0);
}
}