forked from 790hanu/Annex-qr-code-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkipChar.java
More file actions
33 lines (29 loc) · 738 Bytes
/
SkipChar.java
File metadata and controls
33 lines (29 loc) · 738 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
package Strings;
public class SkipChar {
public static void main(String[] args) {
System.out.println(skip("bccdaad"));
}
static void skip(String p, String up){
if(up.isEmpty()){
System.out.println(p);
return;
}
char ch = up.charAt(0);
if(ch=='d'){
skip(p,up.substring(1));
}else{
skip(p+ch,up.substring(1));
}
}
static String skip( String up){
if(up.isEmpty()){
return "";
}
char ch = up.charAt(0);
if(ch=='d'){
return skip(up.substring(1));
}else{
return ch + skip(up.substring(1));
}
}
}