Skip to content

Commit e0cb6f4

Browse files
Merge pull request #90 from TheThakurSahab/StringManipulation
String manipulation
2 parents 082a46b + 036f550 commit e0cb6f4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Generate subtes of a given string
2+
*/
3+
import java.util.Scanner;
4+
public class StringSubset {
5+
static void SubSets(String str, String current, int index){
6+
if(index==str.length()) {
7+
System.out.println(current + " ");
8+
return;
9+
}
10+
/* Two cases for every character
11+
(i) We consider the character as part of current subset
12+
(ii) We do not consider current character as part of current subset */
13+
SubSets(str,current+str.charAt(index), index+1);
14+
SubSets(str,current, index+1);
15+
16+
}
17+
//Driver code
18+
public static void main(String[] args) {
19+
Scanner scan = new Scanner(System.in);
20+
System.out.println("Enter the string you want to generate substrings of");
21+
String str = scan.nextLine();
22+
int index =0;
23+
String current = "";
24+
SubSets(str,current ,index);
25+
}
26+
}

0 commit comments

Comments
 (0)