-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubSequenceApproach2.java
More file actions
43 lines (29 loc) · 934 Bytes
/
Copy pathSubSequenceApproach2.java
File metadata and controls
43 lines (29 loc) · 934 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package Lecture12.RecursionArraylists;
import java.util.ArrayList;
import com.sun.org.apache.regexp.internal.recompile;
public class SubSequenceApproach2 {
public static void subSequence(String ques, String asf) {
if (ques.length() == 0) {
System.out.print(asf + ",");
} else {
char ch = ques.charAt(0);
subSequence(ques.substring(1), "" + asf);
subSequence(ques.substring(1), asf + ch);
}
}
public static void subSequenceWithASCII(String ques, String asf) {
if (ques.length() == 0) {
System.out.print(asf + ",");
return;
}
char ch = ques.charAt(0);
subSequenceWithASCII(ques.substring(1), asf);
subSequenceWithASCII(ques.substring(1), asf + ch);
subSequenceWithASCII(ques.substring(1), asf + (int) ch);
}
public static void main(String[] args) {
subSequence("abc", "");
System.out.println();
subSequenceWithASCII("ab", "");
}
}